3v4l.org

run code in 300+ PHP versions simultaneously
<?php #$str = 'doom2:'; #var_dump(implode(':',explode(':',$str))); exit; $arr = array('var'=> array('sub2' => 'notouch')); function strAssign(&$arr,$str,$val,$trail=true){ if(!empty($str)){ $str = explode(':',$str); $key = array_shift($str); if((isset($arr[$key]) && gettype($arr[$key])!='array') || !isset($arr[$key])){ $arr[$key] = array(); } strAssign($arr[$key],implode(':',$str),$val); }else{ if($trail){ $arr[] = $val; }else{ $arr = $val; } } } strAssign($arr,'var:sub:sub2:','value'); var_dump($arr);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KCjlZ
function name:  (null)
number of ops:  10
compiled vars:  !0 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   ASSIGN                                                   !0, <array>
   22     1        INIT_FCALL                                               'strassign'
          2        SEND_REF                                                 !0
          3        SEND_VAL                                                 'var%3Asub%3Asub2%3A'
          4        SEND_VAL                                                 'value'
          5        DO_FCALL                                      0          
   23     6        INIT_FCALL                                               'var_dump'
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                                 
          9      > RETURN                                                   1

Function strassign:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 41
Branch analysis from position: 7
2 jumps found. (Code = 46) Position 1 = 18, Position 2 = 22
Branch analysis from position: 18
2 jumps found. (Code = 47) Position 1 = 23, Position 2 = 26
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 29
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 46
Branch analysis from position: 46
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
Branch analysis from position: 26
Branch analysis from position: 22
Branch analysis from position: 41
2 jumps found. (Code = 43) Position 1 = 42, Position 2 = 45
Branch analysis from position: 42
1 jumps found. (Code = 42) Position 1 = 46
Branch analysis from position: 46
Branch analysis from position: 45
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KCjlZ
function name:  strAssign
number of ops:  47
compiled vars:  !0 = $arr, !1 = $str, !2 = $val, !3 = $trail, !4 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV_INIT                                        !3      <true>
    7     4        ISSET_ISEMPTY_CV                                 ~5      !1
          5        BOOL_NOT                                         ~6      ~5
          6      > JMPZ                                                     ~6, ->41
    8     7    >   INIT_FCALL                                               'explode'
          8        SEND_VAL                                                 '%3A'
          9        SEND_VAR                                                 !1
         10        DO_ICALL                                         $7      
         11        ASSIGN                                                   !1, $7
    9    12        INIT_FCALL                                               'array_shift'
         13        SEND_REF                                                 !1
         14        DO_ICALL                                         $9      
         15        ASSIGN                                                   !4, $9
   10    16        ISSET_ISEMPTY_DIM_OBJ                         0  ~11     !0, !4
         17      > JMPZ_EX                                          ~11     ~11, ->22
         18    >   FETCH_DIM_R                                      ~12     !0, !4
         19        GET_TYPE                                         ~13     ~12
         20        IS_NOT_EQUAL                                     ~14     ~13, 'array'
         21        BOOL                                             ~11     ~14
         22    > > JMPNZ_EX                                         ~11     ~11, ->26
         23    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~15     !0, !4
         24        BOOL_NOT                                         ~16     ~15
         25        BOOL                                             ~11     ~16
         26    > > JMPZ                                                     ~11, ->29
   11    27    >   ASSIGN_DIM                                               !0, !4
         28        OP_DATA                                                  <array>
   13    29    >   INIT_FCALL_BY_NAME                                       'strAssign'
         30        CHECK_FUNC_ARG                                           
         31        FETCH_DIM_FUNC_ARG                               $18     !0, !4
         32        SEND_FUNC_ARG                                            $18
         33        INIT_FCALL                                               'implode'
         34        SEND_VAL                                                 '%3A'
         35        SEND_VAR                                                 !1
         36        DO_ICALL                                         $19     
         37        SEND_VAR_NO_REF_EX                                       $19
         38        SEND_VAR_EX                                              !2
         39        DO_FCALL                                      0          
         40      > JMP                                                      ->46
   15    41    > > JMPZ                                                     !3, ->45
   16    42    >   ASSIGN_DIM                                               !0
         43        OP_DATA                                                  !2
         44      > JMP                                                      ->46
   18    45    >   ASSIGN                                                   !0, !2
   21    46    > > RETURN                                                   null

End of function strassign

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.37 ms | 1403 KiB | 22 Q