3v4l.org

run code in 300+ PHP versions simultaneously
<?PHP $paths = [ '/cars$', '.*/cars$', '^cars/.*/', '/trucks$', '.*/trucks$' ]; $url = 'some-site.com/cars'; $res = array_filter($paths, function ($v) USE ($url) { return preg_match('~'.$v.'~', $url); }); echo count($res)." patterns matched:\n"; print_r($res); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aX8jI
function name:  (null)
number of ops:  16
compiled vars:  !0 = $paths, !1 = $url, !2 = $res
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   12     1        ASSIGN                                                   !1, 'some-site.com%2Fcars'
   14     2        INIT_FCALL                                               'array_filter'
          3        SEND_VAR                                                 !0
          4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FaX8jI%3A14%240'
          5        BIND_LEXICAL                                             ~5, !1
   16     6        SEND_VAL                                                 ~5
          7        DO_ICALL                                         $6      
   14     8        ASSIGN                                                   !2, $6
   18     9        COUNT                                            ~8      !2
         10        CONCAT                                           ~9      ~8, '+patterns+matched%3A%0A'
         11        ECHO                                                     ~9
   19    12        INIT_FCALL                                               'print_r'
         13        SEND_VAR                                                 !2
         14        DO_ICALL                                                 
   21    15      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FaX8jI%3A14%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aX8jI
function name:  {closure}
number of ops:  10
compiled vars:  !0 = $v, !1 = $url
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   15     2        INIT_FCALL                                               'preg_match'
          3        CONCAT                                           ~2      '%7E', !0
          4        CONCAT                                           ~3      ~2, '%7E'
          5        SEND_VAL                                                 ~3
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                         $4      
          8      > RETURN                                                   $4
   16     9*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FaX8jI%3A14%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
129.18 ms | 1401 KiB | 19 Q