note 49604 added to function.strpos

From: Date: Wed, 02 Feb 2005 21:08:58 +0000
Subject: note 49604 added to function.strpos
Groups: php.notes 
Request: Send a blank email to php-notes+get-84390@lists.php.net to get a copy of this message
re: bwongar here is a refined version of your function <?php function strpos_array($haystack, $needle){ $offset = 0; // Offset for strpos() $array = array(); while (true) { $result = strpos($haystack, $needle, $offset); if ($result === FALSE) { // If result is false (no more instances found), kill the while loop break; } else { array_push($array,$result); $offset++; // Offset is set 1 character after previous occurence } } return $array; } ?> ---- Manual Page -- http://www.php.net/manual/en/function.strpos.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+49604 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+49604&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+49604&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+49604&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+49604&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+49604&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+49604&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#84390) next »