3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array("05:11","05:21","05:24","05:31","05:34","05:41","05:44","05:50","05:54"); function getClosest($search, $arr) { $result = array_search($search, $arr); return $result && $result<sizeof($arr)-1 ? $arr[$result+1] : ""; } echo getClosest("05:34", $array); echo "\n"; echo getClosest("05:50", $array); echo "\n"; var_dump(getClosest("05:54", $array));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/acUgt
function name:  (null)
number of ops:  21
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    9     1        INIT_FCALL                                               'getclosest'
          2        SEND_VAL                                                 '05%3A34'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $2      
          5        ECHO                                                     $2
   10     6        ECHO                                                     '%0A'
   11     7        INIT_FCALL                                               'getclosest'
          8        SEND_VAL                                                 '05%3A50'
          9        SEND_VAR                                                 !0
         10        DO_FCALL                                      0  $3      
         11        ECHO                                                     $3
   12    12        ECHO                                                     '%0A'
   13    13        INIT_FCALL                                               'var_dump'
         14        INIT_FCALL                                               'getclosest'
         15        SEND_VAL                                                 '05%3A54'
         16        SEND_VAR                                                 !0
         17        DO_FCALL                                      0  $4      
         18        SEND_VAR                                                 $4
         19        DO_ICALL                                                 
         20      > RETURN                                                   1

Function getclosest:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 8, Position 2 = 12
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 17
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/acUgt
function name:  getClosest
number of ops:  20
compiled vars:  !0 = $search, !1 = $arr, !2 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    5     2        INIT_FCALL                                               'array_search'
          3        SEND_VAR                                                 !0
          4        SEND_VAR                                                 !1
          5        DO_ICALL                                         $3      
          6        ASSIGN                                                   !2, $3
    6     7      > JMPZ_EX                                          ~5      !2, ->12
          8    >   COUNT                                            ~6      !1
          9        SUB                                              ~7      ~6, 1
         10        IS_SMALLER                                       ~8      !2, ~7
         11        BOOL                                             ~5      ~8
         12    > > JMPZ                                                     ~5, ->17
         13    >   ADD                                              ~9      !2, 1
         14        FETCH_DIM_R                                      ~10     !1, ~9
         15        QM_ASSIGN                                        ~11     ~10
         16      > JMP                                                      ->18
         17    >   QM_ASSIGN                                        ~11     ''
         18    > > RETURN                                                   ~11
    7    19*     > RETURN                                                   null

End of function getclosest

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.76 ms | 1013 KiB | 18 Q