note 53902 deleted from function.preg-match-all by sean
| From: | sean@php.net | Date: | Thu, 16 Jun 2005 13:50:57 +0000 |
| Subject: | note 53902 deleted from function.preg-match-all by sean | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-90538@lists.php.net to get a copy of this message | ||
Note Submitter: pablo dot seb at gmail dot com
----
By assigning a name to a capturing group, you can easily reference it by name. (?P<name>group)
captures the match of group into the backreference "name". You can reference the contents
of the group with the numbered backreference or the named backreference
<?php
preg_match_all('|(a)(?P<x>b)(?P<y>c)(d)|','abcdefgabcdefg',$sub);
echo $sub[2][0]; //b
echo '<br />';
echo $sub['y'][0]; //c
?>