3v4l.org

run code in 300+ PHP versions simultaneously
<?php function ascending_array($array){ if (!is_array($array)){ $array = explode(",", $array); } $new = array(); $flag = true; iter: $array = array_values($array); // recount array values with new offsets (isset($min["max"])) ? $min["value"] = $min["max"] : $min["value"] = $array[0]; $min["offset"] = 0; for ($i=0;$i<count($array);$i++){ if ($array[$i] < $min["value"]){ // redefine min values each time if statement executed $min["value"] = $array[$i]; $min["offset"] = $i; } if ($flag){ // execute only first time if ($array[$i] > $min["value"]){ // define max value from array $min["max"] = $array[$i]; } $flag = false; } if ($i === (count($array)-1)){ // last array element array_push($new,$min["value"]); unset($array[$min["offset"]]); } } if (count($array)!=0){ goto iter; } print_r($new); } $arr = array(50,25,98,45); print_r(ascending_array($arr)); // 25 45 50 98
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [0] => 25 [1] => 45 [2] => 50 [3] => 98 )

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