Find Common Words - 2 Strings - Rewrite String Word Order
- Is it possible to 开发者_如何学Ccompare two different strings...
- Finding common words between the two strings...
- Rewriting $string2 to be outputted the same as $string1...
For example:
$string1 = "Kelly Clarkson - Gone";
$string2 = "Gone - Kelly Clarkson";
Pretty much looking to straighten out song titles, so that they are all in the same format. Some songs are "Artist Name - Song Title" and some songs are "Song Title - Artist Name".
There is one slight curve ball... Not all the songs have a hyphen separating the artist name and song title. Some songs may separate with a space or a colon. So that kind of eliminates my idea of searching for contents before and after the separator.
You could do the following process to find out if two strings are the same song
1) Remove hypens, extra spaces, colons, etc
2) Sort the string by words
3) Compare strings
If they match, it's the same song.
Although, you can't really know which part of the string is actually the artist and which is the song title, unless you have some sort of dictionary to compare to
精彩评论