3v4l.org

run code in 300+ PHP versions simultaneously
<?php $rates = array( 'apple' => array( 'red' => array( 'rate' => 1.19, 'resume' => 'This is a red apple.' ), 'green' => array( 'rate' => 0.99, 'resume' => 'This is a green apple.' ), 'yellow' => array( 'rate' => 0.89, 'resume' => 'This is a yellow apple.' ), ) ); $cart = array( 'apple' => array( '0' => red, '1' => green ) ); $total = 0; foreach ($cart as $key => $arr) { if (isset($rates[$key])) { foreach ($arr as $value) { $total += $rates[$key]['rate'][$value] ?? 0; } } } echo $total;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 24
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 24
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 23
Branch analysis from position: 13
2 jumps found. (Code = 77) Position 1 = 14, Position 2 = 22
Branch analysis from position: 14
2 jumps found. (Code = 78) Position 1 = 15, Position 2 = 22
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 22
Branch analysis from position: 23
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
filename:       /in/vsEvA
function name:  (null)
number of ops:  27
compiled vars:  !0 = $rates, !1 = $cart, !2 = $total, !3 = $arr, !4 = $key, !5 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   22     1        FETCH_CONSTANT                                   ~7      'red'
          2        INIT_ARRAY                                       ~8      ~7, 0
   23     3        FETCH_CONSTANT                                   ~9      'green'
          4        ADD_ARRAY_ELEMENT                                ~8      ~9, 1
          5        INIT_ARRAY                                       ~10     ~8, 'apple'
   20     6        ASSIGN                                                   !1, ~10
   27     7        ASSIGN                                                   !2, 0
   28     8      > FE_RESET_R                                       $13     !1, ->24
          9    > > FE_FETCH_R                                       ~14     $13, !3, ->24
         10    >   ASSIGN                                                   !4, ~14
   29    11        ISSET_ISEMPTY_DIM_OBJ                         0          !0, !4
         12      > JMPZ                                                     ~16, ->23
   30    13    > > FE_RESET_R                                       $17     !3, ->22
         14    > > FE_FETCH_R                                               $17, !5, ->22
   31    15    >   FETCH_DIM_IS                                     ~18     !0, !4
         16        FETCH_DIM_IS                                     ~19     ~18, 'rate'
         17        FETCH_DIM_IS                                     ~20     ~19, !5
         18        COALESCE                                         ~21     ~20
         19        QM_ASSIGN                                        ~21     0
         20        ASSIGN_OP                                     1          !2, ~21
   30    21      > JMP                                                      ->14
         22    >   FE_FREE                                                  $17
   28    23    > > JMP                                                      ->9
         24    >   FE_FREE                                                  $13
   35    25        ECHO                                                     !2
   36    26      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.03 ms | 998 KiB | 13 Q