3v4l.org

run code in 300+ PHP versions simultaneously
<?php $alist = array ( array('Effective Supervisory', '18/07/1992', '19/07/1992'), array('Effective Supervisory', '16/08/1992', '16/08/1992'), array('Effective Supervisory', '19/08/1992', '19/08/1992'), array('Seven Habits', '19/09/1992', '19/09/1992'), array('Seven Habits', '20/09/1992', '20/09/1992'), array('Effective Supervisory', '29/08/1992', '29/08/1992'), ); function searchForKeyValues($searchVal, $array) { $keys = array(); $n = 0; foreach ($array as $key => $val) { if ($val[0] === $searchVal) { $keys[$n++] = $key; } } return $keys; } function getAllKeys($array, $arrayCol) { $keys = array(); $n = 0; foreach ($array as $key => $val) { $keys[$n++] = $val[$arrayCol]; } return array_unique($keys); } $allKeys = getAllKeys($alist, 0); var_dump($allKeys); foreach ($allKeys as $searchVal) { echo "Searching for '$searchVal' :\n"; var_dump(searchForKeyValues($searchVal, $alist)); } ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 23
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 23
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
filename:       /in/ianBv
function name:  (null)
number of ops:  25
compiled vars:  !0 = $alist, !1 = $allKeys, !2 = $searchVal
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   35     1        INIT_FCALL                                               'getallkeys'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 0
          4        DO_FCALL                                      0  $4      
          5        ASSIGN                                                   !1, $4
   36     6        INIT_FCALL                                               'var_dump'
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                                 
   38     9      > FE_RESET_R                                       $7      !1, ->23
         10    > > FE_FETCH_R                                               $7, !2, ->23
   39    11    >   ROPE_INIT                                     3  ~9      'Searching+for+%27'
         12        ROPE_ADD                                      1  ~9      ~9, !2
         13        ROPE_END                                      2  ~8      ~9, '%27+%3A%0A'
         14        ECHO                                                     ~8
   40    15        INIT_FCALL                                               'var_dump'
         16        INIT_FCALL                                               'searchforkeyvalues'
         17        SEND_VAR                                                 !2
         18        SEND_VAR                                                 !0
         19        DO_FCALL                                      0  $11     
         20        SEND_VAR                                                 $11
         21        DO_ICALL                                                 
   38    22      > JMP                                                      ->10
         23    >   FE_FREE                                                  $7
   43    24      > RETURN                                                   1

Function searchforkeyvalues:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 14
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 14
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 13
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 13
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
filename:       /in/ianBv
function name:  searchForKeyValues
number of ops:  17
compiled vars:  !0 = $searchVal, !1 = $array, !2 = $keys, !3 = $n, !4 = $val, !5 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   14     2        ASSIGN                                                   !2, <array>
   15     3        ASSIGN                                                   !3, 0
   16     4      > FE_RESET_R                                       $8      !1, ->14
          5    > > FE_FETCH_R                                       ~9      $8, !4, ->14
          6    >   ASSIGN                                                   !5, ~9
   17     7        FETCH_DIM_R                                      ~11     !4, 0
          8        IS_IDENTICAL                                             !0, ~11
          9      > JMPZ                                                     ~12, ->13
   18    10    >   POST_INC                                         ~13     !3
         11        ASSIGN_DIM                                               !2, ~13
         12        OP_DATA                                                  !5
   16    13    > > JMP                                                      ->5
         14    >   FE_FREE                                                  $8
   21    15      > RETURN                                                   !2
   22    16*     > RETURN                                                   null

End of function searchforkeyvalues

Function getallkeys:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 12
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 12
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/ianBv
function name:  getAllKeys
number of ops:  18
compiled vars:  !0 = $array, !1 = $arrayCol, !2 = $keys, !3 = $n, !4 = $val, !5 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   26     2        ASSIGN                                                   !2, <array>
   27     3        ASSIGN                                                   !3, 0
   28     4      > FE_RESET_R                                       $8      !0, ->12
          5    > > FE_FETCH_R                                       ~9      $8, !4, ->12
          6    >   ASSIGN                                                   !5, ~9
   29     7        POST_INC                                         ~11     !3
          8        FETCH_DIM_R                                      ~13     !4, !1
          9        ASSIGN_DIM                                               !2, ~11
         10        OP_DATA                                                  ~13
   28    11      > JMP                                                      ->5
         12    >   FE_FREE                                                  $8
   31    13        INIT_FCALL                                               'array_unique'
         14        SEND_VAR                                                 !2
         15        DO_ICALL                                         $14     
         16      > RETURN                                                   $14
   33    17*     > RETURN                                                   null

End of function getallkeys

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.17 ms | 1407 KiB | 19 Q