3v4l.org

run code in 500+ 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 = 17
Branch analysis from position: 4
2 jumps found. (Code = 126) Position 1 = 5, Position 2 = 17
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 12
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 12
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/bgWhG
function name:  delete_entries
number of ops:  19
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, ->17
          4    > > FE_FETCH_RW                                          ~6      $5, !2, ->17
          5    >   ASSIGN                                                       !3, ~6
  105     6        FETCH_DIM_R                                          ~8      !2, 'website'
          7        FETCH_DIM_R                                          ~9      ~8, 'id'
          8        FRAMELESS_ICALL_2                in_array            ~10     ~9, !1
          9      > JMPZ                                                         ~10, ->12
  106    10    >   FETCH_DIM_UNSET                                      $11     !0, 'children'
         11        UNSET_DIM                                                    $11, !3
  108    12    >   INIT_FCALL_BY_NAME                                           'delete_entries'
         13        SEND_VAR_EX                                                  !2
         14        SEND_VAR_EX                                                  !1
         15        DO_FCALL                                          0          
  104    16      > JMP                                                          ->4
         17    >   FE_FREE                                                      $5
  110    18      > RETURN                                                       null

End of function delete_entries

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
167.59 ms | 2581 KiB | 15 Q