如何将Dabble获取所有查询拆分为单独的数组? 我将100万条记录划分为10个数组,并为每个数组进行相同的操作。 我有这个问题因为我找不到超载php内存缓冲区的方法..
非常感谢, 史蒂夫
答案 0 :(得分:0)
您可以使用array_chunk来执行此操作。 基本上将数据库获取结果提供给函数。
您可以查看此链接: http://php.net/manual/tr/function.array-chunk.php
修改强>
for($x=0; $x<30; $x++)
$mainArray[]="Data X";
$split=array_chunk($mainArray,3);
echo "<pre>";
print_r($split);
echo "</pre>";
RESULT
Array
(
[0] => Array
(
[0] => Data X
[1] => Data X
[2] => Data X
)
[1] => Array
(
[0] => Data X
[1] => Data X
[2] => Data X
)
[2] => Array
(
[0] => Data X
[1] => Data X
[2] => Data X
)
[3] => Array
(
[0] => Data X
[1] => Data X
[2] => Data X
)
[4] => Array
(
[0] => Data X
[1] => Data X
[2] => Data X
)
[5] => Array
(
[0] => Data X
[1] => Data X
[2] => Data X
)
[6] => Array
(
[0] => Data X
[1] => Data X
[2] => Data X
)
[7] => Array
(
[0] => Data X
[1] => Data X
[2] => Data X
)
[8] => Array
(
[0] => Data X
[1] => Data X
[2] => Data X
)
[9] => Array
(
[0] => Data X
[1] => Data X
[2] => Data X
)
)