3v4l.org

run code in 300+ PHP versions simultaneously
<?php function str2Arr( $s, $r, $str) { $str = trim( str_replace( $s, $r, $str )); return explode(" ", $str); } $it = "(a(am,bam),b(dam,cam))"; //$to = "a.am, a.bam, b.dam, b.cam"; $search = ['),', '(', ')', ',', 'a a', 'b d', 'ba', 'c']; $replace =[' ', ' ', ' ', ' ', 'a.a','b.d', 'a.ba', 'b.c']; var_dump( implode(", ",( str2Arr( $search, $replace, $it) ) ) );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4AtX6
function name:  (null)
number of ops:  16
compiled vars:  !0 = $it, !1 = $search, !2 = $replace
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   ASSIGN                                                   !0, '%28a%28am%2Cbam%29%2Cb%28dam%2Ccam%29%29'
   13     1        ASSIGN                                                   !1, <array>
   15     2        ASSIGN                                                   !2, <array>
   17     3        INIT_FCALL                                               'var_dump'
          4        INIT_FCALL                                               'implode'
          5        SEND_VAL                                                 '%2C+'
          6        INIT_FCALL                                               'str2arr'
          7        SEND_VAR                                                 !1
          8        SEND_VAR                                                 !2
          9        SEND_VAR                                                 !0
         10        DO_FCALL                                      0  $6      
         11        SEND_VAR                                                 $6
         12        DO_ICALL                                         $7      
         13        SEND_VAR                                                 $7
         14        DO_ICALL                                                 
         15      > RETURN                                                   1

Function str2arr:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4AtX6
function name:  str2Arr
number of ops:  18
compiled vars:  !0 = $s, !1 = $r, !2 = $str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
    5     3        INIT_FCALL                                               'trim'
          4        INIT_FCALL                                               'str_replace'
          5        SEND_VAR                                                 !0
          6        SEND_VAR                                                 !1
          7        SEND_VAR                                                 !2
          8        DO_ICALL                                         $3      
          9        SEND_VAR                                                 $3
         10        DO_ICALL                                         $4      
         11        ASSIGN                                                   !2, $4
    6    12        INIT_FCALL                                               'explode'
         13        SEND_VAL                                                 '+'
         14        SEND_VAR                                                 !2
         15        DO_ICALL                                         $6      
         16      > RETURN                                                   $6
    7    17*     > RETURN                                                   null

End of function str2arr

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.02 ms | 1094 KiB | 19 Q