I am using PHP 4.3.5. I am having a problem in which my script is
crashing when it is using a large array. I have simplified the
problem down to the following example:
<?
set_time_limit( 0);
echo("<html><bo dy>test<br>");
$array1 = array();
$value1 = 1;
for ($index = 0; $index < 160000; $index++)
{
$array1[] = $value1;
}
for($index = 0; $index < 100; $index++)
{
echo("index = $index, value = $array1[$index]<br>");
}
echo("done<br>" );
echo("</body></html>");
exit(0);
?>
If I run the above code it crashes with nothing displayed to the
screen. If I change the loop to go to 80000 instead of 160000 then it
works fine.
Also, I can keep the loop setting at 160000 but change the line:
$array1[] = $value1;
to instead read
$array1[] = 1;
and then it also works fine.
Why does it fail when there are 160000 elements in the array that are
set with a variable?
Thanks,
Mark
crashing when it is using a large array. I have simplified the
problem down to the following example:
<?
set_time_limit( 0);
echo("<html><bo dy>test<br>");
$array1 = array();
$value1 = 1;
for ($index = 0; $index < 160000; $index++)
{
$array1[] = $value1;
}
for($index = 0; $index < 100; $index++)
{
echo("index = $index, value = $array1[$index]<br>");
}
echo("done<br>" );
echo("</body></html>");
exit(0);
?>
If I run the above code it crashes with nothing displayed to the
screen. If I change the loop to go to 80000 instead of 160000 then it
works fine.
Also, I can keep the loop setting at 160000 but change the line:
$array1[] = $value1;
to instead read
$array1[] = 1;
and then it also works fine.
Why does it fail when there are 160000 elements in the array that are
set with a variable?
Thanks,
Mark
Comment