Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP built in array function

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?

like image 973
grep Avatar asked Sep 17 '26 08:09

grep


2 Answers

$new_array = $old_array[0];

...

like image 97
jondavidjohn Avatar answered Sep 18 '26 22:09

jondavidjohn


array_pop() will pop the last (first, if only 1 is present) element.

like image 32
Mārtiņš Briedis Avatar answered Sep 18 '26 20:09

Mārtiņš Briedis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!