3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = array ('Q1 2017'=>'some value', 'Q3 2017'=>'some value', 'Q3 2012'=>'some value', 'Q4 2015'=>'some value', 'Q4 2017'=>'some value', 'Q2 2017'=>'some value'); $new = array(); foreach($arr as $key=>$subarr){ $tempArr = explode(' ', $key); $new[$tempArr[1]][$tempArr[0]] = $subarr; asort($new[$tempArr[1]]); } ksort($new); $secondarr = array(); foreach($new as $k=>$v){ ksort($v); $secondarr[$k] = $v; } foreach($secondarr as $key => $val){ foreach($val as $k=>$v){ $newkey = $k.' '.$key; $finalarr[$newkey] = $v; } } echo "<pre>"; print_r($finalarr);
Output for git.master, git.master_jit, rfc.property-hooks
<pre>Array ( [Q3 2012] => some value [Q4 2015] => some value [Q1 2017] => some value [Q2 2017] => some value [Q3 2017] => some value [Q4 2017] => some value )

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:
62.13 ms | 401 KiB | 8 Q