note 55496 added to function.array-search

From: Date: Fri, 05 Aug 2005 00:57:18 +0000
Subject: note 55496 added to function.array-search
Groups: php.notes 
Request: Send a blank email to php-notes+get-93105@lists.php.net to get a copy of this message
If you give a delimiter (or "glue") to implode() this because a little more robust. To use previous example with slight modification: $array2search = array("pat","ter","n"); $string = implode('|', $array2search); // now "pat|ter|n" if (strpos($string, "pattern" ) !== false) { // wont get here } Now, obviously if you search for strpos($string, "pat|ter|n"), you're going to have problems again... But using a delimiter like this should help avoid most if not all "unforseen" cases. ---- Manual Page -- http://www.php.net/manual/en/function.array-search.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+55496 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+55496&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+55496&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+55496&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+55496&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+55496&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+55496&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+55496&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#93105) next »