在PHP函数内爆可能的限制 [英] possible limitation of implode function in PHP
问题描述
我有以下的code,因为我预期没有返回。我希望最后的结果将是一个字符串:
I have the following code that is not returning as I expected. I was hoping the final result would be a string:
$organizers = array_unique($organizers); // this returns correctly
$organizers = implode(', ', $organizers); // this returns nothing
var_dump($organizers); // no data appears here
exit;
的 array_unique()
函数正确返回的数据,我可以看到它返回的数组。要启动时, $主办方
数组是字符串都在20个字符长度的小一个简单的一维数组。我认为这个问题可能是 $主办方
1万多指数长。是否有可崩盘在一个数组的长度的限制?是否有变通是什么?我找不到手册中任何东西,但我已经彻底测试此code,我相信,误差必须在破灭()
。
The array_unique()
function is returning data correctly and I can see the array it returns. To start, the $organizers
array is a simple 1-D array of strings that all have small lengths under 20 chars. I think the issue might be that $organizers
is more than 10,000 indices long. Are there limitations on the length of an array that can be imploded? Are there work-arounds for that? I cannot find anything in the manual, but I have tested this code thoroughly and I believe the error must be on implode()
.
推荐答案
我不'知道是否有一个限制,但是在我脑海中是taht你也在改变着一个数组转换为字符串。这不应该是在PHP中的问题,但尝试调用一个不同的变量破灭的结果?
I dont' know if there is a limitation, but what comes to my mind is taht you are also transforming an array into a string. This shouldn't be the problem in PHP, but try calling it a different variable for the result of implode?
$organizers = array_unique($organizers); // this returns correctly
$organizers_string = implode(', ', $organizers); // this returns nothing
// This gives it a different space
这篇关于在PHP函数内爆可能的限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!