开发者

Find Common Words - 2 Strings - Rewrite String Word Order

  1. Is it possible to 开发者_如何学Ccompare two different strings...
  2. Finding common words between the two strings...
  3. 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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜