note 50012 added to function.preg-match-all

From: Date: Tue, 15 Feb 2005 12:27:59 +0000
Subject: note 50012 added to function.preg-match-all
Groups: php.notes 
Request: Send a blank email to php-notes+get-85061@lists.php.net to get a copy of this message
If you want to find all positions and his length, you can use the next function: <?php function preg_match_all_positions($pattern, $subject, &$count=null, $flags=0, $offset=0) { for ($count=0; preg_match($pattern, $subject, $match, $flags, $offset); $count++) { $positions[0][] = $pos = strpos($subject, $match[0], $offset); $positions[1][] = $len = strlen($match[0]); $offset = $pos+$len; } return $positions; } ?> ---- Manual Page -- http://www.php.net/manual/en/function.preg-match-all.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+50012 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+50012&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+50012&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+50012&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+50012&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+50012&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+50012&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#85061) next »