martian2k4 Posted March 11, 2006 Share Posted March 11, 2006 Hey, I need to check a string to see if it contains a work, for example$str = "Ham Pizza";if ( $str contains Ham ) {echo "the pizza was ham";}Please help :D. Thanks Link to comment https://forums.phpfreaks.com/topic/4705-help-me-please/ Share on other sites More sharing options...
redarrow Posted March 11, 2006 Share Posted March 11, 2006 [code]<?$str = "Pizza";if ( $str == 'Ham') {echo "the ".$str." was ham";}?>[/code]or[code]$str = "Ham Pizza";if (! $str ) {echo "the pizza was ham";}[/code]I think thats right trygood luck. Link to comment https://forums.phpfreaks.com/topic/4705-help-me-please/#findComment-16480 Share on other sites More sharing options...
wildteen88 Posted March 11, 2006 Share Posted March 11, 2006 You might want to look at [a href=\"http://uk2.php.net/manual/en/function.strpos.php\" target=\"_blank\"]strpost[/a] or if you have PHP5 available use [a href=\"http://uk2.php.net/manual/en/function.stripos.php\" target=\"_blank\"]stripost[/a] for a case insensitive search.For a more accurate search you may want to use [a href=\"http://uk2.php.net/manual/en/function.preg-match.php\" target=\"_blank\"]preg_match[/a] Link to comment https://forums.phpfreaks.com/topic/4705-help-me-please/#findComment-16485 Share on other sites More sharing options...
martian2k4 Posted March 11, 2006 Author Share Posted March 11, 2006 Thanks wildteen, You helped me lots :D Link to comment https://forums.phpfreaks.com/topic/4705-help-me-please/#findComment-16489 Share on other sites More sharing options...
kenrbnsn Posted March 11, 2006 Share Posted March 11, 2006 That would be the function strpos(), not strpost().Ken Link to comment https://forums.phpfreaks.com/topic/4705-help-me-please/#findComment-16494 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.