[nycphp-talk] Accessing First Element of Array
Michael B Allen
ioplex at gmail.com
Sun Aug 26 21:04:48 EDT 2007
On 8/26/07, Ken Downs <ken at secdat.com> wrote:
> look at "each", it is a (mostly deprecate) form of array iteration. The
> sample code in the PHP manual will show exactly what you are looking for.
But again that modifies the array (it advances the cursor).
I guess I can write something myself:
function array_first($array) {
foreach ($array as $element)
return element;
}
>
>
> "Michael B Allen" <ioplex at gmail.com> wrote:
>
> > Hi,
> >
> > How do you access the first element of an array? I'm looking for
> > something like array_shift but without modifying the array.
> >
More information about the talk
mailing list