3v4l.org

run code in 300+ PHP versions simultaneously
<? $string = "var1,'Hello'|var2,'World'|"; $finalArray = array(); $asArr = explode('|', $string ); $find = ["'",]; $replace = ['']; foreach( $asArr as $val ){ $val = str_replace($find, $replace, $val); $tmp = explode( ',', $val ); if (! empty($tmp[0]) && ! empty($tmp[1])) { $finalArray[ $tmp[0] ] = $tmp[1]; } } echo '<pre>';print_r($finalArray);echo '</pre>';
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 34
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 34
Branch analysis from position: 11
2 jumps found. (Code = 46) Position 1 = 25, Position 2 = 28
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 33
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 33
Branch analysis from position: 28
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 34
filename:       /in/i7OWu
function name:  (null)
number of ops:  41
compiled vars:  !0 = $string, !1 = $finalArray, !2 = $asArr, !3 = $find, !4 = $replace, !5 = $val, !6 = $tmp
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, 'var1%2C%27Hello%27%7Cvar2%2C%27World%27%7C'
    3     1        ASSIGN                                                   !1, <array>
    4     2        INIT_FCALL                                               'explode'
          3        SEND_VAL                                                 '%7C'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $9      
          6        ASSIGN                                                   !2, $9
    5     7        ASSIGN                                                   !3, <array>
    6     8        ASSIGN                                                   !4, <array>
    7     9      > FE_RESET_R                                       $13     !2, ->34
         10    > > FE_FETCH_R                                               $13, !5, ->34
    8    11    >   INIT_FCALL                                               'str_replace'
         12        SEND_VAR                                                 !3
         13        SEND_VAR                                                 !4
         14        SEND_VAR                                                 !5
         15        DO_ICALL                                         $14     
         16        ASSIGN                                                   !5, $14
    9    17        INIT_FCALL                                               'explode'
         18        SEND_VAL                                                 '%2C'
         19        SEND_VAR                                                 !5
         20        DO_ICALL                                         $16     
         21        ASSIGN                                                   !6, $16
   10    22        ISSET_ISEMPTY_DIM_OBJ                         1  ~18     !6, 0
         23        BOOL_NOT                                         ~19     ~18
         24      > JMPZ_EX                                          ~19     ~19, ->28
         25    >   ISSET_ISEMPTY_DIM_OBJ                         1  ~20     !6, 1
         26        BOOL_NOT                                         ~21     ~20
         27        BOOL                                             ~19     ~21
         28    > > JMPZ                                                     ~19, ->33
   11    29    >   FETCH_DIM_R                                      ~22     !6, 0
         30        FETCH_DIM_R                                      ~24     !6, 1
         31        ASSIGN_DIM                                               !1, ~22
         32        OP_DATA                                                  ~24
    7    33    > > JMP                                                      ->10
         34    >   FE_FREE                                                  $13
   14    35        ECHO                                                     '%3Cpre%3E'
         36        INIT_FCALL                                               'print_r'
         37        SEND_VAR                                                 !1
         38        DO_ICALL                                                 
         39        ECHO                                                     '%3C%2Fpre%3E'
         40      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
259.34 ms | 1009 KiB | 16 Q