note 94206 deleted from function.in-array by danbrown

From: Date: Thu, 22 Oct 2009 13:15:58 +0000
Subject: note 94206 deleted from function.in-array by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-161975@lists.php.net to get a copy of this message
Note Submitter: gmdebby at gmail dot com ---- @ Will Reiher : Your function to check whether or not a string is in a simple array is not that good, here is why : <?php //your function : $bool = stristr(implode(' ', $array), $word); //note that the returned value is noot a boolean, it's false only when the word is not found ... anyway //lets say i got an array : $array = array("str","ing"); //and a string : $word = "str ing"; //now with your "function" : $result = stristr(implode(' ', $array), $word); //the string is NOT present in the array BUT $result is NOT false //so your function don't work as expected ?> Thats why you better use in_array(); function.

« previous php.notes (#161975) next »