3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array1 = [ ['date' => '1-Sep-2016', 'price1' => 98], ['date' => '1-Oct-2016', 'price1' => 77], ['date' => '1-Nov-2016', 'price1' => 87], ['date' => '1-Dec-2016', 'price1' => 88], ['date' => '1-Jan-2017', 'price1' => 91], ]; $array2 = [ ['date' => '1-Feb-2016', 'price2' => 98], ['date' => '1-Mar-2016', 'price2' => 77], ['date' => '1-Apr-2016', 'price2' => 87], ['date' => '1-May-2016', 'price2' => 88], ['date' => '1-Jun-2016', 'price2' => 91], ['date' => '1-Jul-2016', 'price2' => 88], ['date' => '1-Aug-2016', 'price2' => 88], ['date' => '1-Sep-2016', 'price2' => 88], ['date' => '1-Oct-2016', 'price2' => 88] ]; $stamps = []; $result = []; foreach (array_merge($array1, $array2) as $row) { $stamps[$row['date']] = strtotime($row['date']); $result[$stamps[$row['date']]] = ($result[$stamps[$row['date']]] ?? []) + $row; } array_multisort($stamps, $result); var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 28
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 28
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
filename:       /in/P064u
function name:  (null)
number of ops:  37
compiled vars:  !0 = $array1, !1 = $array2, !2 = $stamps, !3 = $result, !4 = $row
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   11     1        ASSIGN                                                   !1, <array>
   23     2        ASSIGN                                                   !2, <array>
   24     3        ASSIGN                                                   !3, <array>
   25     4        INIT_FCALL                                               'array_merge'
          5        SEND_VAR                                                 !0
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                         $9      
          8      > FE_RESET_R                                       $10     $9, ->28
          9    > > FE_FETCH_R                                               $10, !4, ->28
   26    10    >   FETCH_DIM_R                                      ~11     !4, 'date'
         11        INIT_FCALL                                               'strtotime'
         12        FETCH_DIM_R                                      ~13     !4, 'date'
         13        SEND_VAL                                                 ~13
         14        DO_ICALL                                         $14     
         15        ASSIGN_DIM                                               !2, ~11
         16        OP_DATA                                                  $14
   27    17        FETCH_DIM_R                                      ~15     !4, 'date'
         18        FETCH_DIM_R                                      ~16     !2, ~15
         19        FETCH_DIM_R                                      ~18     !4, 'date'
         20        FETCH_DIM_R                                      ~19     !2, ~18
         21        FETCH_DIM_IS                                     ~20     !3, ~19
         22        COALESCE                                         ~21     ~20
         23        QM_ASSIGN                                        ~21     <array>
         24        ADD                                              ~22     ~21, !4
         25        ASSIGN_DIM                                               !3, ~16
         26        OP_DATA                                                  ~22
   25    27      > JMP                                                      ->9
         28    >   FE_FREE                                                  $10
   29    29        INIT_FCALL                                               'array_multisort'
         30        SEND_REF                                                 !2
         31        SEND_REF                                                 !3
         32        DO_ICALL                                                 
   30    33        INIT_FCALL                                               'var_export'
         34        SEND_VAR                                                 !3
         35        DO_ICALL                                                 
         36      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.69 ms | 1004 KiB | 17 Q