<?php
$s = '1234';
foreach(range(1, strlen($s)) as $i) print substr($s, 0, $i) . "\n";
?>