Voting

: min(one, nine)?
(Example: nine)

The Note You're Voting On

ASchmidt at Anamera dot net
5 years ago
Combining flags
PREG_OFFSET_CAPTURE | PREG_UNMATCHED_AS_NULL
will NOT result in a value of NULL for any submatched subpattern.

Instead still results in an array for each unmatched subpattern, in turn containing:

array (size=2)
0 => null
1 => int -1

Consequently your code needs to expect NULL as the string value:
$matches[ {subpattern+1} ][0] === null
and/or a negative string offset:
$matches[ {subpattern+1} ][1] < 0
to detect any unmatched subpattern!

<< Back to user notes page

To Top