PHP 8.4.24 Released!

Voting

: min(seven, eight)?
(Example: nine)

The Note You're Voting On

ASchmidt at Anamera dot net
6 years ago
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

<< Back to user notes page

To Top