note 27478 added to function.stristr

From: Date: Sat, 07 Dec 2002 08:29:20 +0000
Subject: note 27478 added to function.stristr
Groups: php.notes 
Request: Send a blank email to php-notes+get-40451@lists.php.net to get a copy of this message
This function is tricky! The problem lies when the haystack is a string and the needle is a number. I found out the hard way: This expression: echo $spy = stristr("James Bond 007","007"); will return "007": but this will not: echo $spy = stristr("James Bond 007",007); because 007 is interpreted as a number. Tricky, right? Even if the first parameter could be interpreted as a number, but the second parameter is in quotes, it won't work. For example: echo stristr("555007",007); will not return anything. but this will by the way... echo $spy = stristr(555007,"007"); -- http://www.php.net/manual/en/function.stristr.php http://master.php.net/manage/user-notes.php?action=edit+27478 http://master.php.net/manage/user-notes.php?action=delete+27478 http://master.php.net/manage/user-notes.php?action=reject+27478

« previous php.notes (#40451) next »