Which one would you use?
Basically I only want to get the 1st element from a array, that\'s it.
You would use $arr[ 0 ];
array_shift
removes the first element from the array.
This answer is actually somewhere between incomplete and plain out wrong but, because the comments of the two jon
's I think that it should actually stay up so that others can see that discourse.
The right answer:
reset
is the method to return the first defined index of the array. Even in non-associative arrays, this may not be the 0
index.array_shift
will remove and return the value which is found at reset
The OP made the assumption that $arr[0]
is the first index is not accurate in that particular context.