3v4l.org

run code in 300+ PHP versions simultaneously
<?php $pattern = "/^(?<animal>DOG|CAT)?(?<color>BLUE|RED)?$/i"; $str = "DOG"; if (preg_match($pattern, $str, $matches)) { $matches = array_merge(array('animal' => '', 'color' => ''), $matches); $matches = array_filter($matches, 'is_string', ARRAY_FILTER_USE_KEY); print_r($matches); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 22
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
filename:       /in/nL07C
function name:  (null)
number of ops:  23
compiled vars:  !0 = $pattern, !1 = $str, !2 = $matches
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%2F%5E%28%3F%3Canimal%3EDOG%7CCAT%29%3F%28%3F%3Ccolor%3EBLUE%7CRED%29%3F%24%2Fi'
    4     1        ASSIGN                                                   !1, 'DOG'
    6     2        INIT_FCALL                                               'preg_match'
          3        SEND_VAR                                                 !0
          4        SEND_VAR                                                 !1
          5        SEND_REF                                                 !2
          6        DO_ICALL                                         $5      
          7      > JMPZ                                                     $5, ->22
    7     8    >   INIT_FCALL                                               'array_merge'
          9        SEND_VAL                                                 <array>
         10        SEND_VAR                                                 !2
         11        DO_ICALL                                         $6      
         12        ASSIGN                                                   !2, $6
    8    13        INIT_FCALL                                               'array_filter'
         14        SEND_VAR                                                 !2
         15        SEND_VAL                                                 'is_string'
         16        SEND_VAL                                                 2
         17        DO_ICALL                                         $8      
         18        ASSIGN                                                   !2, $8
    9    19        INIT_FCALL                                               'print_r'
         20        SEND_VAR                                                 !2
         21        DO_ICALL                                                 
   10    22    > > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.47 ms | 1013 KiB | 17 Q