什么是钥匙为PHP中的数组的最大数量 [英] What's the maximum number of keys for an array in php
问题描述
我在写一个PHP脚本,我称之为
I'm writing a php script where I call
$lines = file('base_list.txt');
打破文件成一个阵列。该文件有10多万行吧,这应该是数组10万的元素,但是当我运行
to break a file up into an array. The file has over 100,000 lines in it, which should be 100,000 elements in the array, but when I run
print_r($lines);
exit;
阵列只包含7280元素。
the array only contains 7280 elements.
所以我很好奇,跆拳道?是否有一个数组可以有钥匙的数量有限制吗?我与2GB内存双核2.0GHz的本地运行此(Vista和放大器;虽然IIS);所以我有点糊涂了一个4MB的文件如何抛出这样的结果。
So I'm curious, WTF? Is there a limit on the amount of keys an array can have? I'm running this locally on a dual-core 2.0Ghz with 2GB of RAM (Vista & IIS though); so I'm a little confused how a 4MB file could throw results like this.
编辑:
我可能已经应该提到,我有previously设置了memory_limit到在php.ini 512MB为好。
I have probably should have mentioned that I had previously set memory_limit to 512MB in php.ini as well.
推荐答案
达里尔·海恩,
是啊,有没有在错误日志什么。我甚至增加了错误报告,仍然没有相关的print_r()。
Yeah, there isn't anything in the error logs. I even increased error reporting and still nothing relevant to print_r().
在回应周杰伦:
我跑
In response to Jay: I ran
echo count($lines);
和我得到105546的结果,但仍然的print_r()只显示7280.
and I get a result of 105,546 but still print_r() only displays 7280.
拍摄罗伯·沃克的建议,我环绕在阵列中的所有元素,它实际上包含了所有的结果。这使我相信这个问题是用的print_r()本身,而不是限制数组的大小。
Taking Rob Walker's advice I looped over all the elements in the array and it actually contained all the results. This leads me to believe the issue is with print_r() itself instead of a limit to array size.
另一个奇怪的是,我想在我的REHL服务器之一,结果是理所应当的。现在,我不想责怪这在Windows / IIS,但你去那里。
Another weird thing is that I tried it on one of my REHL servers and the result was as it should be. Now I don't want to blame this on Windows/IIS but there you go.
带着我认为这个问题应该被重新评为它不再是相关的阵列,但print_r的上面。
With the above in mind I think this question should be re-titled as it's no longer relevant to arrays but print_r.
这篇关于什么是钥匙为PHP中的数组的最大数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!