3v4l.org

run code in 300+ PHP versions simultaneously
<?php $groupList = [ [ 'id' => 1, 'parent_id' => null, 'category' => null, 'children_list' => [ [ 'id' => 3, 'parent_id' => 1, 'category' => null, ], [ 'id' => 4, 'parent_id' => 1, 'category' => 'Category number 20', 'children_list' => [ [ 'id' => 7, 'parent_id' => 4, 'category' => null, ], [ 'id' => 8, 'parent_id' => 4, 'category' => 'Category number 30', ], ], ], ], ], 'id' => 2, 'parent_id' => null, 'category' => null, 'children_list' => [ [ 'id' => 5, 'parent_id' => 2, 'category' => null, 'children_list' => [ [ 'id' => 6, 'parent_id' => 5, 'category' => null, ], ], ], ], ]; $filter = array_map(function ($n){return f($n);}, $groupList[0]); echo '<pre>'; print_r($filter); function f(&$a){ foreach($a as $k=>&$r){ if(!$r['category']) unset($a[$k]); if($r['children_list']) $r['children_list']=f($r['children_list']); } return $a; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/T2Rba
function name:  (null)
number of ops:  13
compiled vars:  !0 = $groupList, !1 = $filter
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   53     1        INIT_FCALL                                               'array_map'
          2        DECLARE_LAMBDA_FUNCTION                          ~3      [0]
          3        SEND_VAL                                                 ~3
          4        FETCH_DIM_R                                      ~4      !0, 0
          5        SEND_VAL                                                 ~4
          6        DO_ICALL                                         $5      
          7        ASSIGN                                                   !1, $5
   55     8        ECHO                                                     '%3Cpre%3E'
   56     9        INIT_FCALL                                               'print_r'
         10        SEND_VAR                                                 !1
         11        DO_ICALL                                                 
   64    12      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/T2Rba
function name:  {closure}
number of ops:  6
compiled vars:  !0 = $n
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   53     0  E >   RECV                                             !0      
          1        INIT_FCALL_BY_NAME                                       'f'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0  $1      
          4      > RETURN                                                   $1
          5*     > RETURN                                                   null

End of Dynamic Function 0

Function f:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 2, Position 2 = 18
Branch analysis from position: 2
2 jumps found. (Code = 126) Position 1 = 3, Position 2 = 18
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 8
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 17
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 17
Branch analysis from position: 8
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
filename:       /in/T2Rba
function name:  f
number of ops:  21
compiled vars:  !0 = $a, !1 = $r, !2 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   58     0  E >   RECV                                             !0      
   59     1      > FE_RESET_RW                                      $3      !0, ->18
          2    > > FE_FETCH_RW                                      ~4      $3, !1, ->18
          3    >   ASSIGN                                                   !2, ~4
   60     4        FETCH_DIM_R                                      ~6      !1, 'category'
          5        BOOL_NOT                                         ~7      ~6
          6      > JMPZ                                                     ~7, ->8
          7    >   UNSET_DIM                                                !0, !2
   61     8    >   FETCH_DIM_R                                      ~8      !1, 'children_list'
          9      > JMPZ                                                     ~8, ->17
         10    >   INIT_FCALL_BY_NAME                                       'f'
         11        CHECK_FUNC_ARG                                           
         12        FETCH_DIM_FUNC_ARG                               $10     !1, 'children_list'
         13        SEND_FUNC_ARG                                            $10
         14        DO_FCALL                                      0  $11     
         15        ASSIGN_DIM                                               !1, 'children_list'
         16        OP_DATA                                                  $11
   59    17    > > JMP                                                      ->2
         18    >   FE_FREE                                                  $3
   63    19      > RETURN                                                   !0
   64    20*     > RETURN                                                   null

End of function f

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
716.15 ms | 1019 KiB | 15 Q