Try:
$str = '123456';
$len = strlen($str);
for ($i = 0; $i < $len; $i++) {
echo '<img src="' . $str{$i} . '.jpg" alt="' . $str{$i} . '" border="0">';
}
naturally the images have to be in the same directory, and must be 0.jpg, 1.jpg etc
otherwise you'll have to modify the path, change the image names etc.