3v4l.org

run code in 300+ PHP versions simultaneously
<?php function greatestIndexWhereValueLessThan($haystack, $needle) { foreach ($haystack as $key => $value) { if ($value >= $needle) { break; } } return $key ?? null; } echo greatestIndexWhereValueLessThan([30, 60, 90, 120, 360], 73); echo "\n"; echo greatestIndexWhereValueLessThan([30, 60, 90, 120, 360], 4);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VN7R9
function name:  (null)
number of ops:  12
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   INIT_FCALL                                               'greatestindexwherevaluelessthan'
          1        SEND_VAL                                                 <array>
          2        SEND_VAL                                                 73
          3        DO_FCALL                                      0  $0      
          4        ECHO                                                     $0
   13     5        ECHO                                                     '%0A'
   14     6        INIT_FCALL                                               'greatestindexwherevaluelessthan'
          7        SEND_VAL                                                 <array>
          8        SEND_VAL                                                 4
          9        DO_FCALL                                      0  $1      
         10        ECHO                                                     $1
         11      > RETURN                                                   1

Function greatestindexwherevaluelessthan:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 9
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 9
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 8
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 9
Branch analysis from position: 9
filename:       /in/VN7R9
function name:  greatestIndexWhereValueLessThan
number of ops:  14
compiled vars:  !0 = $haystack, !1 = $needle, !2 = $value, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2      > FE_RESET_R                                       $4      !0, ->9
          3    > > FE_FETCH_R                                       ~5      $4, !2, ->9
          4    >   ASSIGN                                                   !3, ~5
    5     5        IS_SMALLER_OR_EQUAL                                      !1, !2
          6      > JMPZ                                                     ~7, ->8
    6     7    > > JMP                                                      ->9
    4     8    > > JMP                                                      ->3
          9    >   FE_FREE                                                  $4
    9    10        COALESCE                                         ~8      !3
         11        QM_ASSIGN                                        ~8      null
         12      > RETURN                                                   ~8
   10    13*     > RETURN                                                   null

End of function greatestindexwherevaluelessthan

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
137.24 ms | 1001 KiB | 15 Q