3v4l.org

run code in 500+ 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 = 31
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 31
Branch analysis from position: 11
2 jumps found. (Code = 46) Position 1 = 22, Position 2 = 25
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 30
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 30
Branch analysis from position: 25
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
filename:       /in/i7OWu
function name:  (null)
number of ops:  38
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, ->31
         10    > > FE_FETCH_R                                                   $13, !5, ->31
    8    11    >   FRAMELESS_ICALL_3                str_replace         ~14     !3, !4
         12        OP_DATA                                                      !5
         13        ASSIGN                                                       !5, ~14
    9    14        INIT_FCALL                                                   'explode'
         15        SEND_VAL                                                     '%2C'
         16        SEND_VAR                                                     !5
         17        DO_ICALL                                             $16     
         18        ASSIGN                                                       !6, $16
   10    19        ISSET_ISEMPTY_DIM_OBJ                             1  ~18     !6, 0
         20        BOOL_NOT                                             ~19     ~18
         21      > JMPZ_EX                                              ~19     ~19, ->25
         22    >   ISSET_ISEMPTY_DIM_OBJ                             1  ~20     !6, 1
         23        BOOL_NOT                                             ~21     ~20
         24        BOOL                                                 ~19     ~21
         25    > > JMPZ                                                         ~19, ->30
   11    26    >   FETCH_DIM_R                                          ~22     !6, 0
         27        FETCH_DIM_R                                          ~24     !6, 1
         28        ASSIGN_DIM                                                   !1, ~22
         29        OP_DATA                                                      ~24
    7    30    > > JMP                                                          ->10
         31    >   FE_FREE                                                      $13
   14    32        ECHO                                                         '%3Cpre%3E'
         33        INIT_FCALL                                                   'print_r'
         34        SEND_VAR                                                     !1
         35        DO_ICALL                                                     
         36        ECHO                                                         '%3C%2Fpre%3E'
         37      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
164.86 ms | 2388 KiB | 17 Q