PDA

View Full Version : how to search a word in a sentence, it's simple, but i dont't know, how?



smansakra
12-05-2008, 11:47 AM
how to search a word in a sentence, it's simple, but i dont't know, how?

$sentence = "my name is smansakra";
$word_to_search = "smansakra";
//
//
i want like this:

if $word_to_search is found on $sentence, echo "wellcome my dear";

how? :confused:

Twey
12-05-2008, 04:01 PM
function in_sentence($word, $sentence) {
return in_array($word, explode(' ', $sentence));
}