Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Apr 2006
    Posts
    231
    Thanks
    9
    Thanked 1 Time in 1 Post

    Matching Lower & Upper Cases

    Hey all,

    I got a music database that holds songs in this manner:

    ID | Artist | Song_Name | Song_URL

    Now this is pretty much links from everywhere on the web. I have adjusted the "adding" Mechanism to recognize artists on the url and split them up to recognize song name and artists so it injects them accordingly. However, sometimes it is alittle messed up.

    Say I got a url that is http://domain.com/Artist/artist_Song.mp3
    if I inject that, it would be:

    ID | Artist | artist_Song.mp3 | http://domain.com/Artist/artist_Song.mp3

    Now on the Song_Name I have made it to filter the artist name if it exists, but if it isn't capitalized, it doesn't recognize it.

    $song=str_replace('$artist', "", $song);

    how could I extend this function to apply to lower case artist names, say if it was Erind, it would be able to replace erind as well.

    Thanx in advance,
    Erind

  • #2
    Master Coder mlseim's Avatar
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,389
    Thanks
    8
    Thanked 1,077 Times in 1,068 Posts
    So you have this link ...
    http://domain.com/Artist/artist_Song.mp3

    You'll need to save the link "as-is" because filenames are case-sensitive.
    But everything else, you make lower-case, and do all of your filtering
    in lower-case.

    Only when you display the artist's name, you make the first letter of the
    artist's name capital. It remains lower-case in the database, only the
    display on the screen shows it properly.

    Any variables you get from a search box, or from a user, you immediately
    change to lower-case so you can match against your database, which is
    all lower-case, except for the actual link.

  • #3
    Regular Coder
    Join Date
    Apr 2006
    Posts
    231
    Thanks
    9
    Thanked 1 Time in 1 Post
    yeah but when I echo the songs out (results) the names are a bit messed up.

  • #4
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,638
    Thanks
    2
    Thanked 404 Times in 396 Posts
    Quote Originally Posted by Erindesign View Post
    Now on the Song_Name I have made it to filter the artist name if it exists, but if it isn't capitalized, it doesn't recognize it.

    $song=str_replace('$artist', "", $song);

    how could I extend this function to apply to lower case artist names, say if it was Erind, it would be able to replace erind as well.
    If you have PHP5 use str_ireplace() instead of str_replace(). There are PHP4 versions you can find, too(one in the comments).

  • #5
    Master Coder mlseim's Avatar
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,389
    Thanks
    8
    Thanked 1,077 Times in 1,068 Posts
    Give us an example of echoing the names that are messed-up.

    I guess I don't understand the problem yet.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •