3v4l.org

run code in 300+ PHP versions simultaneously
<?php $result = []; $init_arr = [ ['name'=>'grape','num'=>2], ['name'=>'melon','num'=>1] ]; $result['init_arr'] = $init_arr; $removed_arr = my_remove_data( $init_arr, 2 ); $result['removed_arr'] = $removed_arr; array_unshift( $init_arr, ['name'=>'apple','num'=>3] ); $result['added_arr'] = $init_arr; var_dump( $result ); function my_remove_data( $arr, $id ){ foreach($arr as $k1=>$a) { foreach($a as $k2=>$b) { if($b == $id) { unset($arr[$k1]); } } } return $arr; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TLADQ
function name:  (null)
number of ops:  21
compiled vars:  !0 = $result, !1 = $init_arr, !2 = $removed_arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, <array>
    8     2        ASSIGN_DIM                                               !0, 'init_arr'
          3        OP_DATA                                                  !1
   10     4        INIT_FCALL_BY_NAME                                       'my_remove_data'
          5        SEND_VAR_EX                                              !1
          6        SEND_VAL_EX                                              2
          7        DO_FCALL                                      0  $6      
          8        ASSIGN                                                   !2, $6
   11     9        ASSIGN_DIM                                               !0, 'removed_arr'
         10        OP_DATA                                                  !2
   13    11        INIT_FCALL                                               'array_unshift'
         12        SEND_REF                                                 !1
         13        SEND_VAL                                                 <array>
         14        DO_ICALL                                                 
   14    15        ASSIGN_DIM                                               !0, 'added_arr'
         16        OP_DATA                                                  !1
   16    17        INIT_FCALL                                               'var_dump'
         18        SEND_VAR                                                 !0
         19        DO_ICALL                                                 
   27    20      > RETURN                                                   1

Function my_remove_data:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 14
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 14
Branch analysis from position: 4
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 12
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 12
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 11
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 11
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 12
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
filename:       /in/TLADQ
function name:  my_remove_data
number of ops:  17
compiled vars:  !0 = $arr, !1 = $id, !2 = $a, !3 = $k1, !4 = $b, !5 = $k2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   19     2      > FE_RESET_R                                       $6      !0, ->14
          3    > > FE_FETCH_R                                       ~7      $6, !2, ->14
          4    >   ASSIGN                                                   !3, ~7
   20     5      > FE_RESET_R                                       $9      !2, ->12
          6    > > FE_FETCH_R                                       ~10     $9, !4, ->12
          7    >   ASSIGN                                                   !5, ~10
   21     8        IS_EQUAL                                                 !4, !1
          9      > JMPZ                                                     ~12, ->11
   22    10    >   UNSET_DIM                                                !0, !3
   20    11    > > JMP                                                      ->6
         12    >   FE_FREE                                                  $9
   19    13      > JMP                                                      ->3
         14    >   FE_FREE                                                  $6
   26    15      > RETURN                                                   !0
   27    16*     > RETURN                                                   null

End of function my_remove_data

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.99 ms | 1451 KiB | 15 Q