3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $input = '100,100-200, 300, 300, 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); } } foreach ($ranges as $range) { print 'from: '. $range[0]. ' to: '. $range[0] . "\n"; }
based on Y1WsH
Output for 4.3.0 - 7.1.0