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 Quote Link to comment 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. Quote Link to comment 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] Quote Link to comment 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 Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.