3v4l.org

run code in 300+ PHP versions simultaneously
<?php function stringToArrayOfIntegers($string, $uniqueAndSorted = true, $min = null, $max = null) { $array = array(); if(is_int($string) || is_numeric($string)) { $i = @intval($string); if(is_null($min) || ($i >= $min)) { if(is_null($max) || ($i <= $max)) { $array[] = $i; } } } elseif(is_string($string) && strlen($string) && preg_match('/^\\s*([-+]?\\d+)([\\s,;]+([-+]?\\d+))*\\s*$/', $string)) { foreach(split(' ', trim(preg_replace('/[^\\-\\d ]+/', ' ', $string))) as $n) { if(is_numeric($n)) { $i = @intval($string); if(is_null($min) || ($i >= $min)) { if(is_null($max) || ($i <= $max)) { $array[] = $i; } } } } } if($uniqueAndSorted) { if(version_compare(PHP_VERSION, '5.2.9') >= 0) { $array = array_unique($array, SORT_NUMERIC); } else { $array = array_unique($array); } sort($array, SORT_NUMERIC); } return array(); } var_dump(stringToArrayOfIntegers('1'));
Output for git.master, git.master_jit, rfc.property-hooks
array(0) { }

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