3v4l.org

run code in 300+ PHP versions simultaneously
<?php function splitOn($needle, $subject) { $needle = preg_quote($needle, '/'); $pattern = '/(?<!\x5c)(?:\x5c.)*\K' . $needle . '/s'; return preg_split($pattern, $subject); } $rules = 'trim:-,left|replace:[0-9]\|[\,a-z],3|int'; $rules = splitOn('|', $rules); $rules = array_map(function($rule) { [$rule, $arguments] = explode(':', $rule, 1) + ['']; $arguments = splitOn(',', $arguments); return [$rule, $arguments]; }, $rules); var_dump($rules);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6Wavo
function name:  (null)
number of ops:  16
compiled vars:  !0 = $rules
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   ASSIGN                                                   !0, 'trim%3A-%2Cleft%7Creplace%3A%5B0-9%5D%5C%7C%5B%5C%2Ca-z%5D%2C3%7Cint'
   10     1        INIT_FCALL                                               'spliton'
          2        SEND_VAL                                                 '%7C'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $2      
          5        ASSIGN                                                   !0, $2
   12     6        INIT_FCALL                                               'array_map'
          7        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F6Wavo%3A12%240'
   17     8        SEND_VAL                                                 ~4
          9        SEND_VAR                                                 !0
         10        DO_ICALL                                         $5      
   12    11        ASSIGN                                                   !0, $5
   19    12        INIT_FCALL                                               'var_dump'
         13        SEND_VAR                                                 !0
         14        DO_ICALL                                                 
         15      > RETURN                                                   1

Function spliton:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6Wavo
function name:  splitOn
number of ops:  16
compiled vars:  !0 = $needle, !1 = $subject, !2 = $pattern
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    3     2        INIT_FCALL                                               'preg_quote'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 '%2F'
          5        DO_ICALL                                         $3      
          6        ASSIGN                                                   !0, $3
    4     7        CONCAT                                           ~5      '%2F%28%3F%3C%21%5Cx5c%29%28%3F%3A%5Cx5c.%29%2A%5CK', !0
          8        CONCAT                                           ~6      ~5, '%2Fs'
          9        ASSIGN                                                   !2, ~6
    5    10        INIT_FCALL                                               'preg_split'
         11        SEND_VAR                                                 !2
         12        SEND_VAR                                                 !1
         13        DO_ICALL                                         $8      
         14      > RETURN                                                   $8
    6    15*     > RETURN                                                   null

End of function spliton

Function %00%7Bclosure%7D%2Fin%2F6Wavo%3A12%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6Wavo
function name:  {closure}
number of ops:  21
compiled vars:  !0 = $rule, !1 = $arguments
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   13     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '%3A'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 1
          5        DO_ICALL                                         $2      
          6        ADD                                              ~3      $2, <array>
          7        FETCH_LIST_R                                     $4      ~3, 0
          8        ASSIGN                                                   !0, $4
          9        FETCH_LIST_R                                     $6      ~3, 1
         10        ASSIGN                                                   !1, $6
         11        FREE                                                     ~3
   14    12        INIT_FCALL                                               'spliton'
         13        SEND_VAL                                                 '%2C'
         14        SEND_VAR                                                 !1
         15        DO_FCALL                                      0  $8      
         16        ASSIGN                                                   !1, $8
   16    17        INIT_ARRAY                                       ~10     !0
         18        ADD_ARRAY_ELEMENT                                ~10     !1
         19      > RETURN                                                   ~10
   17    20*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F6Wavo%3A12%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.87 ms | 1403 KiB | 25 Q