3v4l.org

run code in 300+ PHP versions simultaneously
<?php $csv_array = array ( 0 => array ( 0 => 'delivery_postcode', 1 => 'tracking' ), 1 => array ( 0 => 'A0N2H0', 1 => 3197653232325 ), 2 => array ( 0 => 'A3N 3A6', 1 => 31976532323252 ) ); $orders = array( array ( 'orders_id' => 32061, 'delivery_postcode' => 'V0R 2M0' ), array ( 'orders_id' => 32011, 'delivery_postcode' => 'L8B1H5' ), array ( 'orders_id' => 31846, 'delivery_postcode' => 'K0E1K0' ), array ( 'orders_id' => 31822, 'delivery_postcode' => 'A0N 2H0' ), array ( 'orders_id' => 31503, 'delivery_postcode' => 'V0J 1Z2' ) ); $csv_keys = array_shift($csv_array); $csv_array = array_map(function ($a) use ($csv_keys) { return array_combine($csv_keys, array(str_replace(' ', '', $a[0]), $a[1])); }, $csv_array); $tracked = array(); foreach ($orders as $order) { if (($key = array_search(str_replace(' ', '', $order['delivery_postcode']), array_column($csv_array, 'delivery_postcode'))) !== false) { $tracked[] = array_merge($order, $csv_array[$key]); } } print_r($tracked);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 15, Position 2 = 41
Branch analysis from position: 15
2 jumps found. (Code = 78) Position 1 = 16, Position 2 = 41
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 33, Position 2 = 40
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 40
Branch analysis from position: 41
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 41
filename:       /in/GD3KZ
function name:  (null)
number of ops:  46
compiled vars:  !0 = $csv_array, !1 = $orders, !2 = $csv_keys, !3 = $tracked, !4 = $order, !5 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   21     1        ASSIGN                                                   !1, <array>
   44     2        INIT_FCALL                                               'array_shift'
          3        SEND_REF                                                 !0
          4        DO_ICALL                                         $8      
          5        ASSIGN                                                   !2, $8
   45     6        INIT_FCALL                                               'array_map'
          7        DECLARE_LAMBDA_FUNCTION                          ~10     [0]
          8        BIND_LEXICAL                                             ~10, !2
   47     9        SEND_VAL                                                 ~10
         10        SEND_VAR                                                 !0
   45    11        DO_ICALL                                         $11     
         12        ASSIGN                                                   !0, $11
   49    13        ASSIGN                                                   !3, <array>
   50    14      > FE_RESET_R                                       $14     !1, ->41
         15    > > FE_FETCH_R                                               $14, !4, ->41
   51    16    >   INIT_FCALL                                               'array_search'
         17        INIT_FCALL                                               'str_replace'
         18        SEND_VAL                                                 '+'
         19        SEND_VAL                                                 ''
         20        FETCH_DIM_R                                      ~15     !4, 'delivery_postcode'
         21        SEND_VAL                                                 ~15
         22        DO_ICALL                                         $16     
         23        SEND_VAR                                                 $16
         24        INIT_FCALL                                               'array_column'
         25        SEND_VAR                                                 !0
         26        SEND_VAL                                                 'delivery_postcode'
         27        DO_ICALL                                         $17     
         28        SEND_VAR                                                 $17
         29        DO_ICALL                                         $18     
         30        ASSIGN                                           ~19     !5, $18
         31        TYPE_CHECK                                  1018          ~19
         32      > JMPZ                                                     ~20, ->40
   52    33    >   INIT_FCALL                                               'array_merge'
         34        SEND_VAR                                                 !4
         35        FETCH_DIM_R                                      ~22     !0, !5
         36        SEND_VAL                                                 ~22
         37        DO_ICALL                                         $23     
         38        ASSIGN_DIM                                               !3
         39        OP_DATA                                                  $23
   50    40    > > JMP                                                      ->15
         41    >   FE_FREE                                                  $14
   55    42        INIT_FCALL                                               'print_r'
         43        SEND_VAR                                                 !3
         44        DO_ICALL                                                 
         45      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GD3KZ
function name:  {closure}
number of ops:  17
compiled vars:  !0 = $a, !1 = $csv_keys
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   45     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   46     2        INIT_FCALL                                               'array_combine'
          3        SEND_VAR                                                 !1
          4        INIT_FCALL                                               'str_replace'
          5        SEND_VAL                                                 '+'
          6        SEND_VAL                                                 ''
          7        FETCH_DIM_R                                      ~2      !0, 0
          8        SEND_VAL                                                 ~2
          9        DO_ICALL                                         $3      
         10        INIT_ARRAY                                       ~4      $3
         11        FETCH_DIM_R                                      ~5      !0, 1
         12        ADD_ARRAY_ELEMENT                                ~4      ~5
         13        SEND_VAL                                                 ~4
         14        DO_ICALL                                         $6      
         15      > RETURN                                                   $6
   47    16*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.39 ms | 1012 KiB | 21 Q