PHP 8.4.24 Released!

Voting

: max(zero, three)?
(Example: nine)

The Note You're Voting On

chat dot noir at arcor dot de
8 years ago
Note that if a parenthesed group is not matched, its key may or may not be present in $matches. For instance,

<?php preg_match('/(foo)?(bar)?(baz)?/', 'bar', $matches);
print_r($matches); 

// outputs
// Array
// (
//     [0] => bar
//     [1] => 
//     [2] => bar
// )
?>
Note that there is no element with key '3' in $matches, but an element with key '1' (the empty string). This inconsistent behavior also applies to named groups.

<< Back to user notes page

To Top