note 27478 deleted from function.stristr by danbrown
| From: | danbrown@php.net | Date: | Fri, 28 Nov 2008 20:08:55 +0000 |
| Subject: | note 27478 deleted from function.stristr by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-147183@lists.php.net to get a copy of this message | ||
Note Submitter: sam_at_compasspointmedia.com
----
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");