note 117285 added to function.preg-match-all
| From: | DanielKlein | Date: | Sun, 17 May 2015 05:27:00 +0000 |
| Subject: | note 117285 added to function.preg-match-all | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-202571@lists.php.net to get a copy of this message | ||
The code that john at mccarthy dot net posted is not necessary. If you want your results grouped by
individual match simply use:
<?
preg_match_all($pattern, $string, $matches, PREG_SET_ORDER);
?>
E.g.
<?
preg_match_all('/([GH])([12])([!?])/', 'G1? H2!', $matches); // Default
PREG_PATTERN_ORDER
// $matches = array(0 => array(0 => 'G1?', 1 => 'H2!'),
// 1 => array(0 => 'G', 1 => 'H'),
// 2 => array(0 => '1', 1 => '2'),
// 3 => array(0 => '?', 1 => '!'))
preg_match_all('/([GH])([12])([!?])/', 'G1? H2!', $matches, PREG_SET_ORDER);
// $matches = array(0 => array(0 => 'G1?', 1 => 'G', 2 =>
'1', 3 => '?'),
// 1 => array(0 => 'H2!', 1 => 'H', 2 =>
'2', 3 => '!'))
?>
----
Server IP: 72.52.91.14
Probable Submitter: 1.44.198.2
----
Manual Page -- http://php.net/manual/en/function.preg-match-all.php
Edit -- https://master.php.net/note/edit/117285
Del: integrated -- https://master.php.net/note/delete/117285/integrated
Del: useless -- https://master.php.net/note/delete/117285/useless
Del: bad code -- https://master.php.net/note/delete/117285/bad+code
Del: spam -- https://master.php.net/note/delete/117285/spam
Del: non-english -- https://master.php.net/note/delete/117285/non-english
Del: in docs -- https://master.php.net/note/delete/117285/in+docs
Del: other reasons-- https://master.php.net/note/delete/117285
Reject -- https://master.php.net/note/reject/117285
Search -- https://master.php.net/manage/user-notes.php