开发者

PHP built in array function

开发者 https://www.devze.com 2023-03-19 18:19 出处:网络
Lets say I end up with an array like such: Array ( [0] => Array ( [0] => user [1] => pass ) ) may开发者_运维百科be as a result of passing an array through a function and using func_get_a

Lets say I end up with an array like such:

Array ( [0] => Array ( [0] => user 
                       [1] => pass
                     ) 
)

may开发者_运维百科be 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?


$new_array = $old_array[0];

...


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.


I would recommend array_shift as it removes and returns the first element off of the beginning of the array.

0

精彩评论

暂无评论...
验证码 换一张
取 消