3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ //... 'name' => ['value' => 'Raj KB'], 'street' => ['value' => 'Street ABC'], 'city' => ['value' => 'Dubai'], 'country_id' => ['value' => 'UAE'], 'region' => ['value' => 'DXB'], 'region_id' => ['value' => 11], 'zip_code' => ['value' => 12345], 'city_id' => ['value' => 22], //... ]; $ordered_keys = ['country_id' => 256, 'region' => 257, 'region_id' => 258, 'city' => 259, 'city_id' => 260]; $index = 0; $result = []; foreach ($array as $k => $v) { if ( isset($ordered_keys[$k]) ) { $result[$k] = $ordered_keys[$k]; if ( $index < 255 ) $index = 512; } else { $result[$k] = $index++; } } asort($result); foreach($result as $k => $v) { $result[$k] = $array[$k]; } print_r($result);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [name] => Array ( [value] => Raj KB ) [street] => Array ( [value] => Street ABC ) [country_id] => Array ( [value] => UAE ) [region] => Array ( [value] => DXB ) [region_id] => Array ( [value] => 11 ) [city] => Array ( [value] => Dubai ) [city_id] => Array ( [value] => 22 ) [zip_code] => Array ( [value] => 12345 ) )

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:
36.64 ms | 407 KiB | 5 Q