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);
Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.28, 8.4.1 - 8.4.14, 8.4.16, 8.5.0 - 8.5.1
array ( 0 => array ( 'product_sku' => '1', 'product_type' => 'Type', 'contact_name' => 'Contact Name', 'phone' => '0000 000 000', 'full_price' => '50.00', 'product_name' => 'Product Name', 'product_id' => '1', 'rating' => '0', ), 1 => 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', ), )
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.

preferences:
129.96 ms | 408 KiB | 5 Q