3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $input = '100,100-200, 300, 320, 400-200'; $params = explode(',', $input); $ranges = array(); foreach ($params as $param) { $param = trim($param); if (strpos('-', $param) !== FALSE) { $range = explode('-', $param); } else { $range = array($param, $param); } $ranges[] = $range; } foreach ($ranges as $range) { print 'from: '. $range[0]. ' to: '. $range[1] . "\n"; }
based on tsPhV
Output for 4.3.0 - 7.1.0
from: 100 to: 100 from: 100-200 to: 100-200 from: 300 to: 300 from: 320 to: 320 from: 400-200 to: 400-200