3v4l.org

run code in 300+ PHP versions simultaneously
<?php $json = '[ { "id": "1", "country_id": "1", "spec_id": "1", "spec_children_name": "SUPER REDUCES RATE", "spec_children_first_col": "", "spec_children_second_col": "", "spec_children_third_col": "" }, { "id": "2", "country_id": "1", "spec_id": "1", "spec_children_name": "REDUCED RATE", "spec_children_first_col": "10% and 13%", "spec_children_second_col": "food, passenger transport, accommodotion, newspaper, pharmaceutical products,\u2026.(10%); plants, antiques, firewood, cinema, theatre,\u2026(13%)", "spec_children_third_col": "" }, { "id": "3", "country_id": "1", "spec_id": "1", "spec_children_name": "MEDIUM RATE", "spec_children_first_col": "", "spec_children_second_col": "", "spec_children_third_col": "" }, { "id": "4", "country_id": "1", "spec_id": "1", "spec_children_name": "STANDARD RATE", "spec_children_first_col": "20%", "spec_children_second_col": "other", "spec_children_third_col": "" }, { "id": "5", "country_id": "1", "spec_id": "1", "spec_children_name": "ZERO RATE", "spec_children_first_col": "", "spec_children_second_col": "", "spec_children_third_col": "" }, { "id": "104", "country_id": "2", "spec_id": "1", "spec_children_name": "REDUCED RATE", "spec_children_first_col": "TEXT 547", "spec_children_second_col": "TEXT 1000", "spec_children_third_col": "" } ]'; $objects = json_decode($json); $rules = ['spec_id' => 'ASC', 'spec_children_name' => 'DESC']; uasort($objects, function($a, $b) use ($rules) { foreach ($rules as $column => $order) { $left[] = $order === 'ASC' ? $a->$column : $b->$column; $right[] = $order === 'ASC' ? $b->$column : $a->$column; } return $left <=> $right; }); var_export($objects);
Output for git.master, git.master_jit, rfc.property-hooks
array ( 4 => (object) array( 'id' => '5', 'country_id' => '1', 'spec_id' => '1', 'spec_children_name' => 'ZERO RATE', 'spec_children_first_col' => '', 'spec_children_second_col' => '', 'spec_children_third_col' => '', ), 0 => (object) array( 'id' => '1', 'country_id' => '1', 'spec_id' => '1', 'spec_children_name' => 'SUPER REDUCES RATE', 'spec_children_first_col' => '', 'spec_children_second_col' => '', 'spec_children_third_col' => '', ), 3 => (object) array( 'id' => '4', 'country_id' => '1', 'spec_id' => '1', 'spec_children_name' => 'STANDARD RATE', 'spec_children_first_col' => '20%', 'spec_children_second_col' => 'other', 'spec_children_third_col' => '', ), 1 => (object) array( 'id' => '2', 'country_id' => '1', 'spec_id' => '1', 'spec_children_name' => 'REDUCED RATE', 'spec_children_first_col' => '10% and 13%', 'spec_children_second_col' => 'food, passenger transport, accommodotion, newspaper, pharmaceutical products,….(10%); plants, antiques, firewood, cinema, theatre,…(13%)', 'spec_children_third_col' => '', ), 5 => (object) array( 'id' => '104', 'country_id' => '2', 'spec_id' => '1', 'spec_children_name' => 'REDUCED RATE', 'spec_children_first_col' => 'TEXT 547', 'spec_children_second_col' => 'TEXT 1000', 'spec_children_third_col' => '', ), 2 => (object) array( 'id' => '3', 'country_id' => '1', 'spec_id' => '1', 'spec_children_name' => 'MEDIUM RATE', 'spec_children_first_col' => '', 'spec_children_second_col' => '', 'spec_children_third_col' => '', ), )

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:
27.81 ms | 411 KiB | 5 Q