note 49739 deleted from function.strpos by cmb

From: Date: Sun, 02 Jun 2019 09:01:40 +0000
Subject: note 49739 deleted from function.strpos by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-211177@lists.php.net to get a copy of this message
Note Submitter: arias at elleondeoro dot com ---- If you want to get all positions in an array, you can use this function. If the optional parameter count is especified, the function will put there the number of matches. <?php function strallpos($pajar, $aguja, $offset=0, &$count=null) { if ($offset > strlen($pajar)) trigger_error("strallpos(): Offset not contained in string.", E_USER_WARNING); $match = array(); for ($count=0; (($pos = strpos($pajar, $aguja, $offset)) !== false); $count++) { $match[] = $pos; $offset = $pos + strlen($aguja); } return $match; } ?>

« previous php.notes (#211177) next »