3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $ranges = explode(',', '221-231,232-242,243-253,254-264,265-275,276-286,287-297,298-308,309-319,320-330,331-341,342-352'); $rackIds = array(); foreach($ranges as $range) { $racks = explode('-', $range); $start = $racks[0]; $end = $racks[1]; for ($i = $start; $i <= $end; $i++) { $rackIds[] = $i; } } foreach ($rackIds as $rackId) { echo $rackId; }
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352