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; } } } function strFetch(&$arr,$str){ if(!empty($str)){ $str = explode(':',$str); $key = array_shift($str); return strFetch($arr[$key],implode(':',$str)); }else{ return $arr; } } #strAssign($arr,'var:sub:sub2:','value'); #var_dump(strFetch($arr,'var:sub2')); print_r(true);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qrjZP
function name:  (null)
number of ops:  5
compiled vars:  !0 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   ASSIGN                                                   !0, <array>
   35     1        INIT_FCALL                                               'print_r'
          2        SEND_VAL                                                 <true>
          3        DO_ICALL                                                 
          4      > 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/qrjZP
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

Function strfetch:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 26
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qrjZP
function name:  strFetch
number of ops:  28
compiled vars:  !0 = $arr, !1 = $str, !2 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   24     2        ISSET_ISEMPTY_CV                                 ~3      !1
          3        BOOL_NOT                                         ~4      ~3
          4      > JMPZ                                                     ~4, ->26
   25     5    >   INIT_FCALL                                               'explode'
          6        SEND_VAL                                                 '%3A'
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                         $5      
          9        ASSIGN                                                   !1, $5
   26    10        INIT_FCALL                                               'array_shift'
         11        SEND_REF                                                 !1
         12        DO_ICALL                                         $7      
         13        ASSIGN                                                   !2, $7
   27    14        INIT_FCALL_BY_NAME                                       'strFetch'
         15        CHECK_FUNC_ARG                                           
         16        FETCH_DIM_FUNC_ARG                               $9      !0, !2
         17        SEND_FUNC_ARG                                            $9
         18        INIT_FCALL                                               'implode'
         19        SEND_VAL                                                 '%3A'
         20        SEND_VAR                                                 !1
         21        DO_ICALL                                         $10     
         22        SEND_VAR_NO_REF_EX                                       $10
         23        DO_FCALL                                      0  $11     
         24      > RETURN                                                   $11
         25*       JMP                                                      ->27
   29    26    > > RETURN                                                   !0
   31    27*     > RETURN                                                   null

End of function strfetch

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
163.36 ms | 1404 KiB | 21 Q