...

View Full Version : Matching Lower & Upper Cases



Erindesign
03-14-2008, 04:16 AM
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

mlseim
03-14-2008, 05:06 AM
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.

Erindesign
03-14-2008, 09:39 PM
yeah but when I echo the songs out (results) the names are a bit messed up.

Inigoesdr
03-14-2008, 10:43 PM
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() (php.net/str_ireplace) instead of str_replace(). There are PHP4 versions you can find, too(one in the comments).

mlseim
03-14-2008, 11:18 PM
Give us an example of echoing the names that are messed-up.

I guess I don't understand the problem yet.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum