note 37070 deleted from function.stristr by danbrown

From: Date: Fri, 28 Nov 2008 20:08:45 +0000
Subject: note 37070 deleted from function.stristr by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-147182@lists.php.net to get a copy of this message
Note Submitter: paulphp at springfrog dot com ---- Regarding the problem (posted by Dan) of checking for a zero where the zero is at the end of a string, the following will work. Note that !== is used rather than != which doesn't work. $total = "Your total is 0"; $srchstrng = "0"; if (stristr($total, $srchstrng) !== FALSE) { echo "you have nothing"; } This will correctly output "you have nothing", indicating the zero was correctly identified as being in the $total string. (Discovered after experimenting with comparison operators detailed on this page: http://www.php.net/manual/en/language.operators.comparison .)

« previous php.notes (#147182) next »