3v4l.org

run code in 300+ PHP versions simultaneously
<?php $stock = array("7", "5", "3"); $request = array("3", "6", "3"); var_dump(validate_order($stock, $request)); // false $stock = array("7", "5", "3"); $request = array("3", "4", "3"); var_dump(validate_order($stock, $request)); // true function validate_order($stock, $request) { foreach ($stock as $key=>$value) // Fixed length, loop through if ($value < $request[$key]) return false; // Return false only if the stock is less than the request return true; // If all indexes are higher in stock than request, return true }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jqsvo
function name:  (null)
number of ops:  19
compiled vars:  !0 = $stock, !1 = $request
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, <array>
    5     2        INIT_FCALL                                               'var_dump'
          3        INIT_FCALL_BY_NAME                                       'validate_order'
          4        SEND_VAR_EX                                              !0
          5        SEND_VAR_EX                                              !1
          6        DO_FCALL                                      0  $4      
          7        SEND_VAR                                                 $4
          8        DO_ICALL                                                 
    7     9        ASSIGN                                                   !0, <array>
    8    10        ASSIGN                                                   !1, <array>
    9    11        INIT_FCALL                                               'var_dump'
         12        INIT_FCALL_BY_NAME                                       'validate_order'
         13        SEND_VAR_EX                                              !0
         14        SEND_VAR_EX                                              !1
         15        DO_FCALL                                      0  $8      
         16        SEND_VAR                                                 $8
         17        DO_ICALL                                                 
   16    18      > RETURN                                                   1

Function validate_order:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 11
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 11
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 10
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/jqsvo
function name:  validate_order
number of ops:  14
compiled vars:  !0 = $stock, !1 = $request, !2 = $value, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   12     2      > FE_RESET_R                                       $4      !0, ->11
          3    > > FE_FETCH_R                                       ~5      $4, !2, ->11
          4    >   ASSIGN                                                   !3, ~5
   13     5        FETCH_DIM_R                                      ~7      !1, !3
          6        IS_SMALLER                                               !2, ~7
          7      > JMPZ                                                     ~8, ->10
   14     8    >   FE_FREE                                                  $4
          9      > RETURN                                                   <false>
   12    10    > > JMP                                                      ->3
         11    >   FE_FREE                                                  $4
   15    12      > RETURN                                                   <true>
   16    13*     > RETURN                                                   null

End of function validate_order

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.88 ms | 1401 KiB | 15 Q