If I had an array like:
$array['foo'] = 400;
$array['bar'] = 'xyz';
And I wanted to get the first item out of that array without knowing the key for it, how would I do that? Is there a function for this?
If I had an array like:
$array['foo'] = 400;
$array['bar'] = 'xyz';
And I wanted to get the first item out of that array without knowing the key for it, how would I do that? Is there a function for this?
You can make:
reset()
gives you the first value of the array if you have an element inside the array:It also gives you
FALSE
in case the array is empty.I do this to get the first and last value. This works with more values too.