OK, unless I'm wrong, the following shortened function should work for you:
<?
$orig_array = array("Peggy", "Mary", "Joan");
$new_array = rest($orig_array)
function rest($orig_array) {
while(list($ak,$val) = each($orig_array)) {
for ($ltr = 0; $ltr < strlen($val); $ltr++) {
echo"<li>" . $ltr . "...." . strlen($val) ;
if ($ltr > 10) break;
$new_array[$ak][$ltr] = $val[$ltr];
}
}
return $new_array);
?>
This will give you the following array:
Array (
[0] =>
Array (
[0] => P
[1] => e
[2] => g
[3] => g
[4] => y )
[1] =>
Array (
[0] => M
[1] => a
[2] => r
[3] => y )
[2] =>
Array (
[0] => J
[1] => o
[2] => a
[3] => n )
)
I think that's what your asking for. In my cae, I need to only call the function once, where you arerecursively calling it within itself, the most likely sorce of your timeout. The oinly other thing I'd suggest in regard to your code is to combine the if statements at the beginnning to one, it is possible that an empty array could be read by the else portion of the second conditional block. Let me know if this works, I'd be interested to find a solution.