<?php$s = '1234';foreach(range(1, strlen($s)) as $i) print substr($s, 0, $i) . "\n";?>
Standard input is empty
1 12 123 1234
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!