Which function is more efficient, memory-wise for splitting an array in PHP; array_slice() OR array_chunk()?
对于在PHP中拆分数组,哪种函数更有效,内存方面; array_slice()或array_chunk()?
Thanks.
谢谢。
UPDATE After profiling both functions, memory usage seems to be the same, however array_chunk is faster by a tiny margin.
更新在分析两个函数之后,内存使用情况似乎相同,但是array_chunk的速度很快。
2 个解决方案
#2
1
What do you want in return? If you just want one chunk, use the slice.
你想要什么作为回报?如果您只想要一个块,请使用切片。
#1
#2
1
What do you want in return? If you just want one chunk, use the slice.
你想要什么作为回报?如果您只想要一个块,请使用切片。