PDA

View Full Version : Contains


mr_ego
10-11-2002, 01:39 PM
I cant figure out how to work out PHP's Patern Syntax.

how do i structure an IF statement to figure out
if a certain string [eg: $a] contains another
string [$b]?

firepages
10-11-2002, 02:32 PM
<?
if(strstr($haystack,$needle)){
echo "$needle was found in $haystack";
}else{
echo "no $needle found in $haystack";
}
?>


also look at stristr() for a case insensitive search.