3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array1 = array ( "products" => array( "category" => array( array( "product_sku" => "1", "product_type" => "Type", "customer_contact_name" => "Contact Name", "customer_telephone" => "0000 000 000", "customer_email" => "email@email.com", "customer_postcode" => "PostCode", "additional_info" => array( "some information" => "some information" ), "full_price" => "50.00", "product_name" => "Product Name", "product_id" => "1", "customer_rating" => "0" ), array( "product_sku" => "2", "product_type" => "Type", "customer_contact_name" => "Contact Name", "customer_telephone" => "0000 000 000", "customer_email" => "email@email.com", "customer_postcode" => "PostCode", "additional_info" => array( "some information" => "some information" ), "full_price" => "100.00", "product_name" => "Product Name", "product_id" => "2", "customer_rating" => "0" ) ) ) ); $array2 = array ( array( "product_sku" => "1", "product_type" => "Type", "contact_name" => "Contact Name", "phone" => "0000 000 000", "full_price" => "0.00", "product_name" => "Product Name", "product_id" => "1", "rating" => "0" ), array( "product_sku" => "3", "product_type" => "Type", "contact_name" => "Contact Name", "phone" => "0000 000 000", "full_price" => "80.00", "product_name" => "Product Name", "product_id" => "3", "rating" => "0" ) ); $skuFullPrices = array_column( $array1['products']['category'], 'full_price', 'product_sku' ); $array2 = array_map( fn($row) => array_replace( $row, ['full_price' => $skuFullPrices[$row['product_sku']] ?? $row['full_price']] ), $array2 ); usort( $array2, fn($a, $b) => $a['full_price'] <=> $b['full_price'] ); var_export($array2);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/r8bcn
function name:  (null)
number of ops:  26
compiled vars:  !0 = $array1, !1 = $array2, !2 = $skuFullPrices
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                   !0, <array>
   41     1        ASSIGN                                                   !1, <array>
   64     2        INIT_FCALL                                               'array_column'
   65     3        FETCH_DIM_R                                      ~5      !0, 'products'
          4        FETCH_DIM_R                                      ~6      ~5, 'category'
          5        SEND_VAL                                                 ~6
   66     6        SEND_VAL                                                 'full_price'
   67     7        SEND_VAL                                                 'product_sku'
   64     8        DO_ICALL                                         $7      
          9        ASSIGN                                                   !2, $7
   69    10        INIT_FCALL                                               'array_map'
   70    11        DECLARE_LAMBDA_FUNCTION                          ~9      [0]
         12        BIND_LEXICAL                                             ~9, !2
   74    13        SEND_VAL                                                 ~9
   75    14        SEND_VAR                                                 !1
   69    15        DO_ICALL                                         $10     
         16        ASSIGN                                                   !1, $10
   77    17        INIT_FCALL                                               'usort'
   78    18        SEND_REF                                                 !1
   79    19        DECLARE_LAMBDA_FUNCTION                          ~12     [1]
   80    20        SEND_VAL                                                 ~12
   77    21        DO_ICALL                                                 
   81    22        INIT_FCALL                                               'var_export'
         23        SEND_VAR                                                 !1
         24        DO_ICALL                                                 
         25      > 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/r8bcn
function name:  {closure}
number of ops:  14
compiled vars:  !0 = $row, !1 = $skuFullPrices
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   70     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   71     2        INIT_FCALL                                               'array_replace'
   72     3        SEND_VAR                                                 !0
   73     4        FETCH_DIM_R                                      ~2      !0, 'product_sku'
          5        FETCH_DIM_IS                                     ~3      !1, ~2
          6        COALESCE                                         ~4      ~3
          7        FETCH_DIM_R                                      ~5      !0, 'full_price'
          8        QM_ASSIGN                                        ~4      ~5
          9        INIT_ARRAY                                       ~6      ~4, 'full_price'
         10        SEND_VAL                                                 ~6
   71    11        DO_ICALL                                         $7      
   73    12      > RETURN                                                   $7
   74    13*     > RETURN                                                   null

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/r8bcn
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   79     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        FETCH_DIM_R                                      ~2      !0, 'full_price'
          3        FETCH_DIM_R                                      ~3      !1, 'full_price'
          4        SPACESHIP                                        ~4      ~2, ~3
          5      > RETURN                                                   ~4
   80     6*     > RETURN                                                   null

End of Dynamic Function 1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.31 ms | 1019 KiB | 18 Q