3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = array("A" => "aa", "B" => ["A" => "aaa", "B" => "bb"], "C" => "cc", "D" => ["E" =>"ee"]); function array_filter_recursive(array &$array, callable $callback) { foreach ($array as $key => &$value) { if ($callback($key, $value)) unset($array[$key]); else if (is_array($value)) array_filter_recursive($value, $callback); } } function sanitizedArray(&$arr, $restricted, $keys = false) { foreach($restricted as $val) { array_filter_recursive($arr, function($k, $v) use ($val, $keys) {return $keys ? ($val === $k) : ($val === $v);}); } } sanitizedArray($arr, ["A","E", "D"], true); print_r($arr);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tqUm9
function name:  (null)
number of ops:  10
compiled vars:  !0 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   18     1        INIT_FCALL                                               'sanitizedarray'
          2        SEND_REF                                                 !0
          3        SEND_VAL                                                 <array>
          4        SEND_VAL                                                 <true>
          5        DO_FCALL                                      0          
   19     6        INIT_FCALL                                               'print_r'
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                                 
          9      > RETURN                                                   1

Function array_filter_recursive:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 3, Position 2 = 19
Branch analysis from position: 3
2 jumps found. (Code = 126) Position 1 = 4, Position 2 = 19
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 12
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 18
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 18
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
filename:       /in/tqUm9
function name:  array_filter_recursive
number of ops:  21
compiled vars:  !0 = $array, !1 = $callback, !2 = $value, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    6     2      > FE_RESET_RW                                      $4      !0, ->19
          3    > > FE_FETCH_RW                                      ~5      $4, !2, ->19
          4    >   ASSIGN                                                   !3, ~5
    7     5        INIT_DYNAMIC_CALL                                        !1
          6        SEND_VAR_EX                                              !3
          7        SEND_VAR_EX                                              !2
          8        DO_FCALL                                      0  $7      
          9      > JMPZ                                                     $7, ->12
         10    >   UNSET_DIM                                                !0, !3
         11      > JMP                                                      ->18
    8    12    >   TYPE_CHECK                                  128          !2
         13      > JMPZ                                                     ~8, ->18
         14    >   INIT_FCALL_BY_NAME                                       'array_filter_recursive'
         15        SEND_VAR_EX                                              !2
         16        SEND_VAR_EX                                              !1
         17        DO_FCALL                                      0          
    6    18    > > JMP                                                      ->3
         19    >   FE_FREE                                                  $4
   10    20      > RETURN                                                   null

End of function array_filter_recursive

Function sanitizedarray:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 13
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 13
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/tqUm9
function name:  sanitizedArray
number of ops:  15
compiled vars:  !0 = $arr, !1 = $restricted, !2 = $keys, !3 = $val
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      <false>
   13     3      > FE_RESET_R                                       $4      !1, ->13
          4    > > FE_FETCH_R                                               $4, !3, ->13
   14     5    >   INIT_FCALL                                               'array_filter_recursive'
          6        SEND_REF                                                 !0
          7        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FtqUm9%3A14%240'
          8        BIND_LEXICAL                                             ~5, !3
          9        BIND_LEXICAL                                             ~5, !2
         10        SEND_VAL                                                 ~5
         11        DO_FCALL                                      0          
   13    12      > JMP                                                      ->4
         13    >   FE_FREE                                                  $4
   16    14      > RETURN                                                   null

End of function sanitizedarray

Function %00%7Bclosure%7D%2Fin%2FtqUm9%3A14%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 8
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tqUm9
function name:  {closure}
number of ops:  12
compiled vars:  !0 = $k, !1 = $v, !2 = $val, !3 = $keys
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
          3        BIND_STATIC                                              !3
          4      > JMPZ                                                     !3, ->8
          5    >   IS_IDENTICAL                                     ~4      !2, !0
          6        QM_ASSIGN                                        ~5      ~4
          7      > JMP                                                      ->10
          8    >   IS_IDENTICAL                                     ~6      !2, !1
          9        QM_ASSIGN                                        ~5      ~6
         10    > > RETURN                                                   ~5
         11*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FtqUm9%3A14%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
177.03 ms | 1403 KiB | 17 Q