PHP内置数组函数
假设我最终得到一个这样的数组:
Array ( [0] => Array ( [0] => user
[1] => pass
)
)
可能是通过函数传递数组并使用 func_get_args() 的结果
在这种情况下,我想摆脱初始数组,所以我最终的结论是:
Array ( [0] => user
[1] => pass
)
我知道我可以创建一个函数来完成此操作,并将每个元素推入一个新数组中,但是,PHP 是否有一些内置功能可以实现此目的?
Lets say I end up with an array like such:
Array ( [0] => Array ( [0] => user
[1] => pass
)
)
maybe as a result of passing an array through a function and using func_get_args()
In this case, I would want to get rid of the initial array, so I just end up with:
Array ( [0] => user
[1] => pass
)
I know I could make a function to accomplish this, and push each element into a new array, however, is there some built in functionality with PHP that can pull this off?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
...
...
array_pop()
将弹出最后一个(第一个,如果只有 1 个)元素。array_pop()
will pop the last (first, if only 1 is present) element.只需取“外部”数组的第一个元素的值即可。
Just take the value of the first element of the "outer" array.
我建议 array_shift 因为它会删除并返回第一个元素数组的开头。
I would recommend array_shift as it removes and returns the first element off of the beginning of the array.