3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ [ 'website' => [ 'id' => 'one' ], 'children' => [ [ 'website' => [ 'id' => 'one.one' ], 'children' => [ [ 'website' => [ 'id' => 'one.one.one' ], 'children' => [ [ 'website' => [ 'id' => 'one.one.one.one' ], 'children' => [] ], [ 'website' => [ 'id' => 'one.one.one.two' ], 'children' => [] ] ] ], [ 'website' => [ 'id' => 'one.one.two' ], 'children' => [ [ 'website' => [ 'id' => 'one.one.two.one' ], 'children' => [] ], [ 'website' => [ 'id' => 'one.one.two.two' ], 'children' => [] ] ] ] ] ], [ 'website' => [ 'id' => 'one.two' ], 'children' => [ [ 'website' => [ 'id' => 'one.two.one' ], 'children' => [ [ 'website' => [ 'id' => 'one.two.one.one' ], 'children' => [] ], [ 'website' => [ 'id' => 'one.two.one.two' ], 'children' => [] ] ] ], [ 'website' => [ 'id' => 'one.two.two' ], 'children' => [ [ 'website' => [ 'id' => 'one.two.two.one' ], 'children' => [] ], [ 'website' => [ 'id' => 'one.two.two.two' ], 'children' => [] ] ] ] ] ] ] ] ]; function delete_entries(&$array, $ids_to_delete) { foreach ($array['children'] as $index => &$child) { if (in_array($child['website']['id'], $ids_to_delete)) { unset($array['children'][$index]); } delete_entries($child, $ids_to_delete); } } foreach ($array as &$arr) { delete_entries($arr, array('one.one.two', 'one.two.one')); } var_export($array);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 2, Position 2 = 8
Branch analysis from position: 2
2 jumps found. (Code = 126) Position 1 = 3, Position 2 = 8
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
filename:       /in/bgWhG
function name:  (null)
number of ops:  13
compiled vars:  !0 = $array, !1 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
  112     1      > FE_RESET_RW                                      $3      !0, ->8
          2    > > FE_FETCH_RW                                              $3, !1, ->8
  113     3    >   INIT_FCALL                                               'delete_entries'
          4        SEND_REF                                                 !1
          5        SEND_VAL                                                 <array>
          6        DO_FCALL                                      0          
  112     7      > JMP                                                      ->2
          8    >   FE_FREE                                                  $3
  116     9        INIT_FCALL                                               'var_export'
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                                 
         12      > RETURN                                                   1

Function delete_entries:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 4, Position 2 = 20
Branch analysis from position: 4
2 jumps found. (Code = 126) Position 1 = 5, Position 2 = 20
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 15
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 15
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
filename:       /in/bgWhG
function name:  delete_entries
number of ops:  22
compiled vars:  !0 = $array, !1 = $ids_to_delete, !2 = $child, !3 = $index
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  103     0  E >   RECV                                             !0      
          1        RECV                                             !1      
  104     2        FETCH_DIM_W                                      $4      !0, 'children'
          3      > FE_RESET_RW                                      $5      $4, ->20
          4    > > FE_FETCH_RW                                      ~6      $5, !2, ->20
          5    >   ASSIGN                                                   !3, ~6
  105     6        INIT_FCALL                                               'in_array'
          7        FETCH_DIM_R                                      ~8      !2, 'website'
          8        FETCH_DIM_R                                      ~9      ~8, 'id'
          9        SEND_VAL                                                 ~9
         10        SEND_VAR                                                 !1
         11        DO_ICALL                                         $10     
         12      > JMPZ                                                     $10, ->15
  106    13    >   FETCH_DIM_UNSET                                  $11     !0, 'children'
         14        UNSET_DIM                                                $11, !3
  108    15    >   INIT_FCALL_BY_NAME                                       'delete_entries'
         16        SEND_VAR_EX                                              !2
         17        SEND_VAR_EX                                              !1
         18        DO_FCALL                                      0          
  104    19      > JMP                                                      ->4
         20    >   FE_FREE                                                  $5
  110    21      > RETURN                                                   null

End of function delete_entries

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.02 ms | 1010 KiB | 16 Q