3v4l.org

run code in 300+ PHP versions simultaneously
<?php function array_search_key( $needle_key, $array ) { foreach($array AS $key=>$value){ if($key == $needle_key) return $value; if(is_array($value)){ if( ($result = array_search_key($needle_key,$value)) !== false) return $result; } } return false; } $item = ( Array ( Array( 'group_roles_name' => 'CREATOR' ) ) ); $value = "CREATOR"; if(is_array($item) && !array_search_key($value,$item)){ // not equal, break de loop $itemFound = false; echo "not found"; } else if(is_array($item) && array_search_key($value,$item)){ echo "found"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 4, Position 2 = 10
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 14
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
2 jumps found. (Code = 46) Position 1 = 16, Position 2 = 21
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 23
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
Branch analysis from position: 21
Branch analysis from position: 10
filename:       /in/XF3cd
function name:  (null)
number of ops:  24
compiled vars:  !0 = $item, !1 = $value, !2 = $itemFound
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   ASSIGN                                                   !0, <array>
   26     1        ASSIGN                                                   !1, 'CREATOR'
   28     2        TYPE_CHECK                                  128  ~5      !0
          3      > JMPZ_EX                                          ~5      ~5, ->10
          4    >   INIT_FCALL                                               'array_search_key'
          5        SEND_VAR                                                 !1
          6        SEND_VAR                                                 !0
          7        DO_FCALL                                      0  $6      
          8        BOOL_NOT                                         ~7      $6
          9        BOOL                                             ~5      ~7
         10    > > JMPZ                                                     ~5, ->14
   29    11    >   ASSIGN                                                   !2, <false>
   30    12        ECHO                                                     'not+found'
         13      > JMP                                                      ->23
   32    14    >   TYPE_CHECK                                  128  ~9      !0
         15      > JMPZ_EX                                          ~9      ~9, ->21
         16    >   INIT_FCALL                                               'array_search_key'
         17        SEND_VAR                                                 !1
         18        SEND_VAR                                                 !0
         19        DO_FCALL                                      0  $10     
         20        BOOL                                             ~9      $10
         21    > > JMPZ                                                     ~9, ->23
   33    22    >   ECHO                                                     'found'
   34    23    > > RETURN                                                   1

Function array_search_key:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 21
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 21
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 9
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 20
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 20
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 20
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
filename:       /in/XF3cd
function name:  array_search_key
number of ops:  24
compiled vars:  !0 = $needle_key, !1 = $array, !2 = $value, !3 = $key, !4 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2      > FE_RESET_R                                       $5      !1, ->21
          3    > > FE_FETCH_R                                       ~6      $5, !2, ->21
          4    >   ASSIGN                                                   !3, ~6
    5     5        IS_EQUAL                                                 !3, !0
          6      > JMPZ                                                     ~8, ->9
          7    >   FE_FREE                                                  $5
          8      > RETURN                                                   !2
    6     9    >   TYPE_CHECK                                  128          !2
         10      > JMPZ                                                     ~9, ->20
    7    11    >   INIT_FCALL_BY_NAME                                       'array_search_key'
         12        SEND_VAR_EX                                              !0
         13        SEND_VAR_EX                                              !2
         14        DO_FCALL                                      0  $10     
         15        ASSIGN                                           ~11     !4, $10
         16        TYPE_CHECK                                  1018          ~11
         17      > JMPZ                                                     ~12, ->20
    8    18    >   FE_FREE                                                  $5
         19      > RETURN                                                   !4
    4    20    > > JMP                                                      ->3
         21    >   FE_FREE                                                  $5
   11    22      > RETURN                                                   <false>
   12    23*     > RETURN                                                   null

End of function array_search_key

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.09 ms | 1403 KiB | 15 Q