note 49604 deleted from function.strpos by tularis
| From: | tularis@php.net | Date: | Wed, 02 Feb 2005 21:28:45 +0000 |
| Subject: | note 49604 deleted from function.strpos by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-84393@lists.php.net to get a copy of this message | ||
Note Submitter: guanfeng at xtra dot co dot nz
Reason: useless
----
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;
}
?>