3v4l.org

run code in 500+ 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 = 38
Branch analysis from position: 15
2 jumps found. (Code = 78) Position 1 = 16, Position 2 = 38
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 37
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 37
Branch analysis from position: 38
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 38
filename:       /in/GD3KZ
function name:  (null)
number of ops:  43
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, ->38
         15    > > FE_FETCH_R                                                   $14, !4, ->38
   51    16    >   INIT_FCALL                                                   'array_search'
         17        FETCH_DIM_R                                          ~15     !4, 'delivery_postcode'
         18        FRAMELESS_ICALL_3                str_replace         ~16     '+', ''
         19        OP_DATA                                                      ~15
         20        SEND_VAL                                                     ~16
         21        INIT_FCALL                                                   'array_column'
         22        SEND_VAR                                                     !0
         23        SEND_VAL                                                     'delivery_postcode'
         24        DO_ICALL                                             $17     
         25        SEND_VAR                                                     $17
         26        DO_ICALL                                             $18     
         27        ASSIGN                                               ~19     !5, $18
         28        TYPE_CHECK                                      1018          ~19
         29      > JMPZ                                                         ~20, ->37
   52    30    >   INIT_FCALL                                                   'array_merge'
         31        SEND_VAR                                                     !4
         32        FETCH_DIM_R                                          ~22     !0, !5
         33        SEND_VAL                                                     ~22
         34        DO_ICALL                                             $23     
         35        ASSIGN_DIM                                                   !3
         36        OP_DATA                                                      $23
   50    37    > > JMP                                                          ->15
         38    >   FE_FREE                                                      $14
   55    39        INIT_FCALL                                                   'print_r'
         40        SEND_VAR                                                     !3
         41        DO_ICALL                                                     
         42      > 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:/in/GD3KZ:45}
number of ops:  14
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        FETCH_DIM_R                                          ~2      !0, 0
          5        FRAMELESS_ICALL_3                str_replace         ~3      '+', ''
          6        OP_DATA                                                      ~2
          7        INIT_ARRAY                                           ~4      ~3
          8        FETCH_DIM_R                                          ~5      !0, 1
          9        ADD_ARRAY_ELEMENT                                    ~4      ~5
         10        SEND_VAL                                                     ~4
         11        DO_ICALL                                             $6      
         12      > RETURN                                                       $6
   47    13*     > RETURN                                                       null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
219.75 ms | 2118 KiB | 20 Q