Imoddedu Posted January 11, 2011 Share Posted January 11, 2011 Is there a php function or script that looks up specific words in a string? I've done some googling, but I'm not sure which functions to use. Basically my end goal is to search for keywords from a inputted string, and respond with a certain set answer from a MySQL database. Link to comment Share on other sites More sharing options...
justsomeguy Posted January 11, 2011 Share Posted January 11, 2011 If you want to determine if a substring is in a string, strpos or stripos is the best way:http://www.php.net/manual/en/function.strpos.php Link to comment Share on other sites More sharing options...
iwato Posted January 12, 2011 Share Posted January 12, 2011 Is there a php function or script that looks up specific words in a string? I've done some googling, but I'm not sure which functions to use. Basically my end goal is to search for keywords from a inputted string, and respond with a certain set answer from a MySQL database.If you have several different key words in the same string that you want to match, you may like to consider the str_word_count() function. For with this function you can capture all of the words of a string as individual elements of an array and then match each element of the array separately against key word.It would likely be more cpu intensive, but you might also find it easier to use.Roddy Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.