3v4l.org

run code in 300+ PHP versions simultaneously
<?php function parse_range_str($str_input) { $arr_result = []; foreach (preg_split('/\s*,\s*/', $str_input) as $str_range) { $arr_range = preg_split('/\s*-\s*/', $str_range); if (isset($arr_range[1])) { $arr_result = array_merge($arr_result, range((int) $arr_range[0], (int) $arr_range[1])); } else { $arr_result[] = (int) $arr_range[0]; } } return $arr_result; } var_dump(parse_range_str('1,2,8-12,16'));
Output for git.master, git.master_jit, rfc.property-hooks
array(8) { [0]=> int(1) [1]=> int(2) [2]=> int(8) [3]=> int(9) [4]=> int(10) [5]=> int(11) [6]=> int(12) [7]=> int(16) }

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