note 37070 added to function.stristr

From: Date: Sat, 01 Nov 2003 15:30:45 +0000
Subject: note 37070 added to function.stristr
Groups: php.notes 
Request: Send a blank email to php-notes+get-59635@lists.php.net to get a copy of this message
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 .) ---- Manual Page -- http://www.php.net/manual/en/function.stristr.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+37070 Delete -- http://master.php.net/manage/user-notes.php?action=delete+37070&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+37070&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#59635) next »