是否有类似python zip的php函数? [英] Is there a php function like python's zip?
本文介绍了是否有类似python zip的php函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Python有一个不错的 zip()
函数.是否有PHP等效项?
Python has a nice zip()
function. Is there a PHP equivalent?
推荐答案
As long as all the arrays are the same length, you can use array_map
with null
as the first argument.
array_map(null, $a, $b, $c, ...);
如果某些数组较短,则将使用null填充最长数组的长度,这与python不同,返回的结果是最短数组的长度.
If some of the arrays are shorter, they will be padded with nulls to the length of the longest, unlike python where the returned result is the length of the shortest array.
这篇关于是否有类似python zip的php函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文