3v4l.org

run code in 300+ PHP versions simultaneously
<?php $items = json_decode(' [ { "Product": "430400", "Delivery": "Delivered", "Size": "24", "UnitPrice": 9.750000 }, { "Product": "430410", "Delivery": "Delivered", "Size": "26", "UnitPrice": 9.750000 } ]',true); function valIsConsistent($items, $key){ if(count($items) == 0){ return false;//hmmm IDK } $prevVal = $items[0][$key]; foreach($items as $item){ if($item[$key] !== $prevVal){ return false; } } return true; } var_dump($items); var_dump(valIsConsistent($items,'Delivery')); var_dump(valIsConsistent($items,'Size'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TspIl
function name:  (null)
number of ops:  23
compiled vars:  !0 = $items
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'json_decode'
          1        SEND_VAL                                                 '%0A%5B%0A++++++%7B%0A++++++++%22Product%22%3A+%22430400%22%2C%0A++++++++%22Delivery%22%3A+%22Delivered%22%2C%0A++++++++%22Size%22%3A+%2224%22%2C%0A++++++++%22UnitPrice%22%3A+9.750000%0A++++++%7D%2C%0A++++++%7B%0A++++++++%22Product%22%3A+%22430410%22%2C%0A++++++++%22Delivery%22%3A+%22Delivered%22%2C%0A++++++++%22Size%22%3A+%2226%22%2C%0A++++++++%22UnitPrice%22%3A+9.750000%0A++++++++%7D%0A%5D'
   17     2        SEND_VAL                                                 <true>
          3        DO_ICALL                                         $1      
    3     4        ASSIGN                                                   !0, $1
   32     5        INIT_FCALL                                               'var_dump'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                                 
   33     8        INIT_FCALL                                               'var_dump'
          9        INIT_FCALL                                               'valisconsistent'
         10        SEND_VAR                                                 !0
         11        SEND_VAL                                                 'Delivery'
         12        DO_FCALL                                      0  $4      
         13        SEND_VAR                                                 $4
         14        DO_ICALL                                                 
   34    15        INIT_FCALL                                               'var_dump'
         16        INIT_FCALL                                               'valisconsistent'
         17        SEND_VAR                                                 !0
         18        SEND_VAL                                                 'Size'
         19        DO_FCALL                                      0  $6      
         20        SEND_VAR                                                 $6
         21        DO_ICALL                                                 
         22      > RETURN                                                   1

Function valisconsistent:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 6
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 17
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 17
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 16
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/TspIl
function name:  valIsConsistent
number of ops:  20
compiled vars:  !0 = $items, !1 = $key, !2 = $prevVal, !3 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   20     2        COUNT                                            ~4      !0
          3        IS_EQUAL                                                 ~4, 0
          4      > JMPZ                                                     ~5, ->6
   21     5    > > RETURN                                                   <false>
   23     6    >   FETCH_DIM_R                                      ~6      !0, 0
          7        FETCH_DIM_R                                      ~7      ~6, !1
          8        ASSIGN                                                   !2, ~7
   24     9      > FE_RESET_R                                       $9      !0, ->17
         10    > > FE_FETCH_R                                               $9, !3, ->17
   25    11    >   FETCH_DIM_R                                      ~10     !3, !1
         12        IS_NOT_IDENTICAL                                         !2, ~10
         13      > JMPZ                                                     ~11, ->16
   26    14    >   FE_FREE                                                  $9
         15      > RETURN                                                   <false>
   24    16    > > JMP                                                      ->10
         17    >   FE_FREE                                                  $9
   29    18      > RETURN                                                   <true>
   30    19*     > RETURN                                                   null

End of function valisconsistent

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
171.99 ms | 1407 KiB | 19 Q