String match

I have this very long string $xmlstr

I want to test if the word "customer" is in that string, how can I do this using PHP ?

Thanks
kapotAsked:
Who is Participating?
 
ldbkuttyCommented:
ofcourse, string functions are "always" faster than Regular Expressions!
0
 
ldbkuttyCommented:
<?php
$xmlstr = 'This is my test string that has the customer word!';
$compareStr = 'customer';
if(substr_count($xmlstr, $compareStr) > 0){
 echo 'Substring matches';
}
else{
 echo 'Does not match';
}
?>

// With PHP 5, other option is to use substr_compare !
0
 
kapotAuthor Commented:
Is it faster than using "eregi()" ?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.