3v4l.org

run code in 300+ PHP versions simultaneously
<?php $product_details = [ "0" => [ "brand_id" => 1, "product_type" => 1, ], "1" => [ "brand_id" => 2, "product_type" => 1, ], "2" => [ "brand_id" => 1, "product_type" => 1, ], "3" => [ "brand_id" => 2, "product_type" => 1, ], ]; function sortByOrder($a, $b) { return $a['brand_id'] - $b['brand_id']; } usort($product_details, 'sortByOrder'); $result = []; foreach ($product_details as $key => $value) { $result['brand_id'.$value['brand_id']][] = $value; } extract($result); print_r($brand_id1); print_r($brand_id2);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [0] => Array ( [brand_id] => 1 [product_type] => 1 ) [1] => Array ( [brand_id] => 1 [product_type] => 1 ) ) Array ( [0] => Array ( [brand_id] => 2 [product_type] => 1 ) [1] => Array ( [brand_id] => 2 [product_type] => 1 ) )

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
182.29 ms | 406 KiB | 5 Q