3v4l.org

run code in 300+ PHP versions simultaneously
<?php $d = [ ['type' => 25500, 'month' => 'July'], ['type' => 5465, 'month' => 'January'], ['type' => 40000, 'month' => 'April'], ['type' => 35000, 'month' => 'June'], ['type' => 10000, 'month' => 'February'] ]; $allmonths = ['January', 'February', 'March', 'April', 'May','June','July','August', 'September','October','November','December']; $lookup = array_column($d, null, 'month'); // assign temporary keys for improved efficiency $result = []; foreach ($allmonths as $month) { $result[] = $lookup[$month] ?? ['type' => 0, 'month' => $month]; } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 19
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 19
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
filename:       /in/4dNfC
function name:  (null)
number of ops:  24
compiled vars:  !0 = $d, !1 = $allmonths, !2 = $lookup, !3 = $result, !4 = $month
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   11     1        ASSIGN                                                   !1, <array>
   15     2        INIT_FCALL                                               'array_column'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 null
          5        SEND_VAL                                                 'month'
          6        DO_ICALL                                         $7      
          7        ASSIGN                                                   !2, $7
   17     8        ASSIGN                                                   !3, <array>
   18     9      > FE_RESET_R                                       $10     !1, ->19
         10    > > FE_FETCH_R                                               $10, !4, ->19
   19    11    >   FETCH_DIM_IS                                     ~12     !2, !4
         12        COALESCE                                         ~13     ~12
         13        INIT_ARRAY                                       ~14     0, 'type'
         14        ADD_ARRAY_ELEMENT                                ~14     !4, 'month'
         15        QM_ASSIGN                                        ~13     ~14
         16        ASSIGN_DIM                                               !3
         17        OP_DATA                                                  ~13
   18    18      > JMP                                                      ->10
         19    >   FE_FREE                                                  $10
   22    20        INIT_FCALL                                               'var_export'
         21        SEND_VAR                                                 !3
         22        DO_ICALL                                                 
         23      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
127.99 ms | 1011 KiB | 15 Q