0
I have an array and will use it in two ways, in one I will use all the elements of this array, and in the other I will limit to , for example, 2 elements, ex:
$array = ('nome'=>'Ribossomo', 'snome'=> 'Silva', 'idade'=> 500);
using all elements:
$user = $array;
now, how can I only get the first 2 elements of this array? for example, the elements nome
and snome
$teste = ?
In fact, the two variables would return an array, only the second would be a "cut" array with the amount of elements I want to be the limit.
– Thiago
edited there, take a look if that’s it
– LocalHost
I had this same idea, but I thought there should be some function that would already do this, and I found a call array_slice, which cuts the array and returns the elements you want, it served me, but thank you for your reply, thank you :)
– Thiago
You’re welcome, I thought you did, but I couldn’t test it here... but I’m glad you found
– LocalHost