3v4l.org

run code in 500+ PHP versions simultaneously
<?php $firstarray = array ( 0 => array ( 0 => '2020-12-01', 1 => 24.00 ), 1 => array ( 0 => '2020-12-05', 1 => 16.00 ), 2 => array ( 0 => '2020-12-07', 1 => 12.00 ), 3 => array ( 0 => '2020-12-15', 1 => 0.00 ), 4 => array ( 0 => '2020-12-16', 1 => 0.00 ), 5 => array ( 0 => '2020-12-16', 1 => 100.00 ) ); $secondarray = array ( 0 => array ( 0 => array ( 0 => '2020-12-01', 1 => '2020-12-05', 2 => 42.00 ), 1 => array ( 0 => '2020-12-06', 1 => '2020-12-08', 2 => 35.00 ), 2 => array ( 0 => '2020-12-09', 1 => '2020-12-12', 2 => 76.00 ), ), 1 => array ( 0 => array ( 0 => '2020-12-01', 1 => '2020-12-05', 2 => 42.00 ), 1 => array ( 0 => '2020-12-06', 1 => '2020-12-08', 2 => 35.00 ), 2 => array ( 0 => '2020-12-09', 1 => '2020-12-12', 2 => 76.00 ), ), 2 => array ( 0 => array ( 0 => '2020-12-04', 1 => '2020-12-09', 2 => 10.00 ), 1 => array ( 0 => '2020-12-10', 1 => '2020-12-13', 2 => 45.00 ), ), 3 => array ( 0 => array ( 0 => '2020-12-04', 1 => '2020-12-09', 2 => 10.00 ), 1 => array ( 0 => '2020-12-10', 1 => '2020-12-13', 2 => 45.00 ), ), 4 => array ( 0 => array ( 0 => '2020-12-04', 1 => '2020-12-09', 2 => 10.00 ), 1 => array ( 0 => '2020-12-10', 1 => '2020-12-13', 2 => 45.00 ), ), 5 => array ( 0 => array ( 0 => '2020-12-01', 1 => '2020-12-05', 2 => 42.00 ), 1 => array ( 0 => '2020-12-06', 1 => '2020-12-08', 2 => 35.00 ), 2 => array ( 0 => '2020-12-09', 1 => '2020-12-12', 2 => 76.00 ) ) ); $prices = array(); foreach ($firstarray as $key => $value) { $price = $value[1]; foreach ($secondarray[$key] as $range) { if ($value[0] >= $range[0] && $value[0] <= $range[1]) { $price = $range[2]; } } $prices[] = $price; } print_r($prices);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 27
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 27
Branch analysis from position: 5
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 23
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 23
Branch analysis from position: 11
2 jumps found. (Code = 46) Position 1 = 15, Position 2 = 19
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 22
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 22
Branch analysis from position: 19
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 23
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
filename:       /in/8vltM
function name:  (null)
number of ops:  32
compiled vars:  !0 = $firstarray, !1 = $secondarray, !2 = $prices, !3 = $value, !4 = $key, !5 = $price, !6 = $range
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   35     1        ASSIGN                                                       !1, <array>
  146     2        ASSIGN                                                       !2, <array>
  147     3      > FE_RESET_R                                           $10     !0, ->27
          4    > > FE_FETCH_R                                           ~11     $10, !3, ->27
          5    >   ASSIGN                                                       !4, ~11
  148     6        FETCH_DIM_R                                          ~13     !3, 1
          7        ASSIGN                                                       !5, ~13
  149     8        FETCH_DIM_R                                          ~15     !1, !4
          9      > FE_RESET_R                                           $16     ~15, ->23
         10    > > FE_FETCH_R                                                   $16, !6, ->23
  150    11    >   FETCH_DIM_R                                          ~17     !3, 0
         12        FETCH_DIM_R                                          ~18     !6, 0
         13        IS_SMALLER_OR_EQUAL                                  ~19     ~18, ~17
         14      > JMPZ_EX                                              ~19     ~19, ->19
         15    >   FETCH_DIM_R                                          ~20     !3, 0
         16        FETCH_DIM_R                                          ~21     !6, 1
         17        IS_SMALLER_OR_EQUAL                                  ~22     ~20, ~21
         18        BOOL                                                 ~19     ~22
         19    > > JMPZ                                                         ~19, ->22
  151    20    >   FETCH_DIM_R                                          ~23     !6, 2
         21        ASSIGN                                                       !5, ~23
  149    22    > > JMP                                                          ->10
         23    >   FE_FREE                                                      $16
  154    24        ASSIGN_DIM                                                   !2
         25        OP_DATA                                                      !5
  147    26      > JMP                                                          ->4
         27    >   FE_FREE                                                      $10
  157    28        INIT_FCALL                                                   'print_r'
         29        SEND_VAR                                                     !2
         30        DO_ICALL                                                     
         31      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
160.63 ms | 1987 KiB | 14 Q