3v4l.org

run code in 300+ PHP versions simultaneously
<?php $pattern = "/{([^{}]+)}/"; $string = "Hi, {Mr.|Mrs.} {Alvin|Dale}! Good Morning!"; $result = preg_split($pattern, $string, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); $result = array_map(function($x) { return explode('|', $x); }, $result); var_export($result);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/F9d34
function name:  (null)
number of ops:  19
compiled vars:  !0 = $pattern, !1 = $string, !2 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%2F%7B%28%5B%5E%7B%7D%5D%2B%29%7D%2F'
    4     1        ASSIGN                                                   !1, 'Hi%2C+%7BMr.%7CMrs.%7D+%7BAlvin%7CDale%7D%21+Good+Morning%21'
    5     2        INIT_FCALL                                               'preg_split'
          3        SEND_VAR                                                 !0
          4        SEND_VAR                                                 !1
          5        SEND_VAL                                                 -1
          6        SEND_VAL                                                 3
          7        DO_ICALL                                         $5      
          8        ASSIGN                                                   !2, $5
    7     9        INIT_FCALL                                               'array_map'
         10        DECLARE_LAMBDA_FUNCTION                          ~7      [0]
    9    11        SEND_VAL                                                 ~7
         12        SEND_VAR                                                 !2
    7    13        DO_ICALL                                         $8      
         14        ASSIGN                                                   !2, $8
   11    15        INIT_FCALL                                               'var_export'
         16        SEND_VAR                                                 !2
         17        DO_ICALL                                                 
         18      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/F9d34
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    8     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '%7C'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $1      
          5      > RETURN                                                   $1
    9     6*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.37 ms | 1013 KiB | 17 Q