Jump to content


Photo

Help me please :(


  • Please log in to reply
4 replies to this topic

#1 martian2k4

martian2k4
  • Members
  • Pip
  • Newbie
  • 8 posts
  • Location??????

Posted 11 March 2006 - 07:39 PM

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

#2 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 11 March 2006 - 07:47 PM

<?

$str = "Pizza";


if ( $str == 'Ham') {

echo "the ".$str." was ham";

}
?>

or


$str = "Ham Pizza";

if (! $str ) {

echo "the pizza was ham";

}



I think thats right try

good luck.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#3 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 11 March 2006 - 07:58 PM

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]

#4 martian2k4

martian2k4
  • Members
  • Pip
  • Newbie
  • 8 posts
  • Location??????

Posted 11 March 2006 - 08:19 PM

Thanks wildteen, You helped me lots :D

#5 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 11 March 2006 - 08:48 PM

That would be the function strpos(), not strpost().

Ken




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users