#!/usr/bin/env php $number) $sum -= $lines[$start++]; if($sum === $number) break; } $subset = array_slice($lines, $start, $i - $start); sort($subset); echo "Range starts on $start and ends on $i.\n"; echo "Lowest {$subset[0]} and highest " . array_pop($subset) . "\n"; echo "(you can sum them yourself)\n"; ?>