[英]php multidimensional SplFixedArray declaration is throwing fatal error
I want to declare SplFixedArray(); 我想声明SplFixedArray(); to save memory consumption. 节省内存消耗。 but it is throwing fatal error. 但这是致命的错误。
$items=new SplFixedArray();
echo "Array Started...";
for($h=0;$h<5000;$h++)
{
for($i=0;$i<24;$i++)
{
$items[$h][$i]=$objSheet->getCellByColumnAndRow($i,$h+1)->getValue();
}
}
The same is working if do not declare new SplFixedArray();
如果不声明new SplFixedArray();
则同样有效new SplFixedArray();
Error: 错误:
Fatal error: Uncaught exception 'RuntimeException' with message 'Index invalid or out of range' in /home/twa/files.php:168 Stack trace: #0 /home/twa/files.php(168): unknown() #1 {main} thrown in /home/twa/files.php on line 168 致命错误:/home/twa/files.php:168中未捕获的异常'RuntimeException',消息'索引无效或超出范围'堆栈跟踪:#0 /home/twa/files.php(168):unknown()#在第168行的/home/twa/files.php中抛出1 {main}
$items=new SplFixedArray(SplFixedArray());
is also failing... 也失败了......
Please let me know correct syntax... 请让我知道正确的语法......
$items = new SplFixedArray(5000);
for ($h=0; $h<5000; $h++) {
$items[$h] = new SplFixedArray(24);
for ($i=0; $i<24; $i++) {
$items[$h][$i] = $objSheet->getCellByColumnAndRow($i,$h+1)->getValue();
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.