3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = ["farm"=> [ "horse"=> [ "rabbit"=> [ "name"=> "alan", "age"=> "21", "size"=> "166", "gender"=> "f" ], ] ] ]; function createList($array, $keySearch, $path=null) { $result = []; foreach ($array as $key => $item) { $basePath = $path === null ? $key : $path. "/" . $key; if (stripos($key, $keySearch) !== false && is_array($item)){ $result[] = ['key' => $key, 'basePath' => $basePath]; } if(is_array($item)) $result = array_merge($result, createList($item, $keySearch, $basePath)); } return $result; } $keySearch = 'a'; $res = createList($array, $keySearch); echo '<pre>'; print_r($res);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/A1J0T
function name:  (null)
number of ops:  12
compiled vars:  !0 = $array, !1 = $keySearch, !2 = $res
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   30     1        ASSIGN                                                   !1, 'a'
   31     2        INIT_FCALL                                               'createlist'
          3        SEND_VAR                                                 !0
          4        SEND_VAR                                                 !1
          5        DO_FCALL                                      0  $5      
          6        ASSIGN                                                   !2, $5
   33     7        ECHO                                                     '%3Cpre%3E'
   34     8        INIT_FCALL                                               'print_r'
          9        SEND_VAR                                                 !2
         10        DO_ICALL                                                 
         11      > RETURN                                                   1

Function createlist:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 41
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 41
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
2 jumps found. (Code = 46) Position 1 = 21, Position 2 = 23
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 28
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 40
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 40
Branch analysis from position: 28
Branch analysis from position: 23
Branch analysis from position: 11
2 jumps found. (Code = 46) Position 1 = 21, Position 2 = 23
Branch analysis from position: 21
Branch analysis from position: 23
Branch analysis from position: 41
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 41
filename:       /in/A1J0T
function name:  createList
number of ops:  44
compiled vars:  !0 = $array, !1 = $keySearch, !2 = $path, !3 = $result, !4 = $item, !5 = $key, !6 = $basePath
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      null
   18     3        ASSIGN                                                   !3, <array>
   19     4      > FE_RESET_R                                       $8      !0, ->41
          5    > > FE_FETCH_R                                       ~9      $8, !4, ->41
          6    >   ASSIGN                                                   !5, ~9
   20     7        TYPE_CHECK                                    2          !2
          8      > JMPZ                                                     ~11, ->11
          9    >   QM_ASSIGN                                        ~12     !5
         10      > JMP                                                      ->14
         11    >   CONCAT                                           ~13     !2, '%2F'
         12        CONCAT                                           ~14     ~13, !5
         13        QM_ASSIGN                                        ~12     ~14
         14    >   ASSIGN                                                   !6, ~12
   21    15        INIT_FCALL                                               'stripos'
         16        SEND_VAR                                                 !5
         17        SEND_VAR                                                 !1
         18        DO_ICALL                                         $16     
         19        TYPE_CHECK                                  1018  ~17     $16
         20      > JMPZ_EX                                          ~17     ~17, ->23
         21    >   TYPE_CHECK                                  128  ~18     !4
         22        BOOL                                             ~17     ~18
         23    > > JMPZ                                                     ~17, ->28
   22    24    >   INIT_ARRAY                                       ~20     !5, 'key'
         25        ADD_ARRAY_ELEMENT                                ~20     !6, 'basePath'
         26        ASSIGN_DIM                                               !3
         27        OP_DATA                                                  ~20
   24    28    >   TYPE_CHECK                                  128          !4
         29      > JMPZ                                                     ~21, ->40
   25    30    >   INIT_FCALL                                               'array_merge'
         31        SEND_VAR                                                 !3
         32        INIT_FCALL_BY_NAME                                       'createList'
         33        SEND_VAR_EX                                              !4
         34        SEND_VAR_EX                                              !1
         35        SEND_VAR_EX                                              !6
         36        DO_FCALL                                      0  $22     
         37        SEND_VAR                                                 $22
         38        DO_ICALL                                         $23     
         39        ASSIGN                                                   !3, $23
   19    40    > > JMP                                                      ->5
         41    >   FE_FREE                                                  $8
   27    42      > RETURN                                                   !3
   28    43*     > RETURN                                                   null

End of function createlist

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
171.88 ms | 1407 KiB | 20 Q