3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = array(1,2,3,7); $last_val = ""; $first_val = ""; $add_val = true; foreach ($arr as $key => $value) { if($first_val == "") $first_val = $value; if(isset($arr[$key+1])) { if($value+1 == $arr[$key+1]) { $last_val = $arr[$key+1]; $add_val = false; } else $add_val = true; } else $add_val = true; if($add_val) { if($last_val != "") $datarange[] = $first_val."-".$last_val; else $datarange[] = $first_val; $first_val = ""; $last_val = ""; } } echo implode(",", $datarange);
Output for git.master, git.master_jit, rfc.property-hooks
1-3,7

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