3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = array("farm" => array("animals"=> array("horses" => array("fred" => "fred", "sam" => "sam", "alan" => "alan", "john" => "john") ) ) ); $search = 'horses'; get_values($arr); function get_values($arr){ global $search; foreach($arr as $key => $value){ if($key == $search){ if(is_array($value)){ $keys = array_keys($value); if(count($keys) > 1){ for($i = 0; $i < count($keys); $i++){ echo '<a href="mypage.php?id=2&dir='.$keys[$i].'"><li>'.$keys[$i].'</li></a>'; } }else{ echo '<a href="mypage.php?id=2&dir='.$keys[0].'"><li>'.$keys[0].'</li></a>'; } } else{ echo $value; } }else{ get_values($value); } } } ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sPBlk
function name:  (null)
number of ops:  6
compiled vars:  !0 = $arr, !1 = $search
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   15     1        ASSIGN                                                   !1, 'horses'
   16     2        INIT_FCALL_BY_NAME                                       'get_values'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0          
   40     5      > RETURN                                                   1

Function get_values:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 44
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 44
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 40
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 38
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 30
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 18
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
1 jumps found. (Code = 42) Position 1 = 43
Branch analysis from position: 43
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 18
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 18
Branch analysis from position: 29
Branch analysis from position: 18
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
Branch analysis from position: 38
1 jumps found. (Code = 42) Position 1 = 43
Branch analysis from position: 43
Branch analysis from position: 40
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 44
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 44
filename:       /in/sPBlk
function name:  get_values
number of ops:  46
compiled vars:  !0 = $arr, !1 = $search, !2 = $value, !3 = $key, !4 = $keys, !5 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
   19     1        BIND_GLOBAL                                              !1, 'search'
   20     2      > FE_RESET_R                                       $6      !0, ->44
          3    > > FE_FETCH_R                                       ~7      $6, !2, ->44
          4    >   ASSIGN                                                   !3, ~7
   21     5        IS_EQUAL                                                 !3, !1
          6      > JMPZ                                                     ~9, ->40
   22     7    >   TYPE_CHECK                                  128          !2
          8      > JMPZ                                                     ~10, ->38
   23     9    >   INIT_FCALL                                               'array_keys'
         10        SEND_VAR                                                 !2
         11        DO_ICALL                                         $11     
         12        ASSIGN                                                   !4, $11
   24    13        COUNT                                            ~13     !4
         14        IS_SMALLER                                               1, ~13
         15      > JMPZ                                                     ~14, ->30
   25    16    >   ASSIGN                                                   !5, 0
         17      > JMP                                                      ->26
   26    18    >   FETCH_DIM_R                                      ~16     !4, !5
         19        CONCAT                                           ~17     '%3Ca+href%3D%22mypage.php%3Fid%3D2%26dir%3D', ~16
         20        CONCAT                                           ~18     ~17, '%22%3E%3Cli%3E'
         21        FETCH_DIM_R                                      ~19     !4, !5
         22        CONCAT                                           ~20     ~18, ~19
         23        CONCAT                                           ~21     ~20, '%3C%2Fli%3E%3C%2Fa%3E'
         24        ECHO                                                     ~21
   25    25        PRE_INC                                                  !5
         26    >   COUNT                                            ~23     !4
         27        IS_SMALLER                                               !5, ~23
         28      > JMPNZ                                                    ~24, ->18
   24    29    > > JMP                                                      ->37
   29    30    >   FETCH_DIM_R                                      ~25     !4, 0
         31        CONCAT                                           ~26     '%3Ca+href%3D%22mypage.php%3Fid%3D2%26dir%3D', ~25
         32        CONCAT                                           ~27     ~26, '%22%3E%3Cli%3E'
         33        FETCH_DIM_R                                      ~28     !4, 0
         34        CONCAT                                           ~29     ~27, ~28
         35        CONCAT                                           ~30     ~29, '%3C%2Fli%3E%3C%2Fa%3E'
         36        ECHO                                                     ~30
   22    37    > > JMP                                                      ->39
   33    38    >   ECHO                                                     !2
   21    39    > > JMP                                                      ->43
   36    40    >   INIT_FCALL_BY_NAME                                       'get_values'
         41        SEND_VAR_EX                                              !2
         42        DO_FCALL                                      0          
   20    43    > > JMP                                                      ->3
         44    >   FE_FREE                                                  $6
   39    45      > RETURN                                                   null

End of function get_values

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.93 ms | 1003 KiB | 14 Q