简体   繁体   English

从同一个PHP函数返回2个不同的数组

[英]Return 2 different arrays from a same php function

I have two multidimensional associative arrays as a result by getting the function parameter.Then I must have to return these two arrays from this function..Can we do that or any other tricky way to do that in php? 通过获取函数参数,我得到了two multidimensional associative arrays我必须从该函数返回这两个数组。我们可以在php中做到这一点或任何其他棘手的方式吗?

Tricky way means getting together that two arrays in single one and get from that like that..Suggesting as a code is better.. 棘手的方式意味着将两个数组组合成一个数组,并从中得到这样的结果。建议编写代码更好。

Thank You... 谢谢...

the simplest way is to create an object and add these two different array in that object and send that object out of the php method. 最简单的方法是创建一个对象,并在该对象中添加这两个不同的数组,然后将该对象从php方法发送出去。 This way the two arrays are send out. 这样,两个阵列都被发送出去。 Other Alternative is to have an an array of arrays, [["abc","addf"],[1,2,3]] 其他选择是拥有一个数组数组[[“” abc“,” addf“],[1,2,3]]

you can use either of the ways to send your output out. 您可以使用任何一种方式将输出发送出去。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM