3v4l.org

run code in 300+ PHP versions simultaneously
<?php $inputArray = array('first-key' => 'first value', 'second-key' => 'second value', array('foo-1' => 'val', 'bar'=> 'value', 'foo-2' => 'val2'), array('soup' => 'carrots', 'fruit' => 'banana') ); $outputArray = array_filter( $inputArray, function ($element) { return ! is_array($element) || ! empty( array_filter($element, function($key) { return strpos($key, 'foo-') === 0; }, ARRAY_FILTER_USE_KEY) ); } ); var_dump($outputArray);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NsgpR
function name:  (null)
number of ops:  11
compiled vars:  !0 = $inputArray, !1 = $outputArray
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   11     1        INIT_FCALL                                               'array_filter'
   12     2        SEND_VAR                                                 !0
   13     3        DECLARE_LAMBDA_FUNCTION                          ~3      [0]
   20     4        SEND_VAL                                                 ~3
   11     5        DO_ICALL                                         $4      
          6        ASSIGN                                                   !1, $4
   23     7        INIT_FCALL                                               'var_dump'
          8        SEND_VAR                                                 !1
          9        DO_ICALL                                                 
         10      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 4, Position 2 = 13
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/NsgpR
function name:  {closure}
number of ops:  15
compiled vars:  !0 = $element
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   14     1        TYPE_CHECK                                  128  ~1      !0
          2        BOOL_NOT                                         ~2      ~1
          3      > JMPNZ_EX                                         ~2      ~2, ->13
   16     4    >   INIT_FCALL                                               'array_filter'
          5        SEND_VAR                                                 !0
          6        DECLARE_LAMBDA_FUNCTION                          ~3      [0]
   18     7        SEND_VAL                                                 ~3
          8        SEND_VAL                                                 2
   16     9        DO_ICALL                                         $4      
   18    10        BOOL_NOT                                         ~5      $4
         11        BOOL_NOT                                         ~6      ~5
         12        BOOL                                             ~2      ~6
         13    > > RETURN                                                   ~2
   20    14*     > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NsgpR
function name:  {closure}
number of ops:  8
compiled vars:  !0 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
   17     1        INIT_FCALL                                               'strpos'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 'foo-'
          4        DO_ICALL                                         $1      
          5        IS_IDENTICAL                                     ~2      $1, 0
          6      > RETURN                                                   ~2
   18     7*     > RETURN                                                   null

End of Dynamic Function 0

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141.8 ms | 1009 KiB | 16 Q