note 124691 added to function.preg-match
| From: | ASchmidt at Anamera dot net | Date: | Thu, 06 Feb 2020 17:58:39 +0000 |
| Subject: | note 124691 added to function.preg-match | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-214013@lists.php.net to get a copy of this message | ||
After the breaking change in 7.4, be aware that count( $matches ) may be different, depending on
PREG_UNMATCHED_AS_NULL flag.
With PREG_UNMATCHED_AS_NULL, count( $matches ) will always be the maximum number of subpatterns.
However, without PREG_UNMATCHED_AS_NULL the $matches array will omit any unmatched subpatterns at
the tail end.
Result forthe first two out of three matches with PREG_OFFSET_CAPTURE flag only:
array (size=3)
0 =>
array (size=2)
0 => string 'may/02' (length=6)
1 => int 0
1 =>
array (size=2)
0 => string 'may' (length=3)
1 => int 0
2 =>
array (size=2)
0 => string '02' (length=2)
1 => int 4
Result for two out of three matches with additional PREG_UNMATCHED_AS_NULL flags:
array (size=4)
0 =>
array (size=2)
0 => string 'may/02' (length=6)
1 => int 0
1 =>
array (size=2)
0 => string 'may' (length=3)
1 => int 0
2 =>
array (size=2)
0 => string '02' (length=2)
1 => int 4
3 =>
array (size=2)
0 => null
1 => int -1
----
Server IP: 45.112.84.4
Probable Submitter: 38.142.137.34 (proxied: 173.63.128.218)
----
Manual Page -- http://php.net/manual/en/function.preg-match.php
Edit -- https://master.php.net/note/edit/124691
Del: integrated -- https://master.php.net/note/delete/124691/integrated
Del: useless -- https://master.php.net/note/delete/124691/useless
Del: bad code -- https://master.php.net/note/delete/124691/bad+code
Del: spam -- https://master.php.net/note/delete/124691/spam
Del: non-english -- https://master.php.net/note/delete/124691/non-english
Del: in docs -- https://master.php.net/note/delete/124691/in+docs
Del: other reasons-- https://master.php.net/note/delete/124691
Reject -- https://master.php.net/note/reject/124691
Search -- https://master.php.net/manage/user-notes.php