|
Posted by Rik Wasmus on 11/15/07 23:19
On Fri, 16 Nov 2007 00:15:52 +0100, mtuller <mituller@gmail.com> wrote:
> I want to get the first record and last record in an array. I don't
> want any other records, but am not finding how to do it. What I am
> doing is pulling out information from a database, where the sql query
> would have a result much like this:
>
> 10
> 11
> 12
> 13
> 14
> 15
> 16
>
> And I want to grab the first and last items in the array, so in this
> case, 10 and 16.
RTFM.....
$first =3D reset($array);
$last =3D end($array);
For ranges, look at array_slice()/array_splice()/count()
-- =
Rik Wasmus
Navigation:
[Reply to this message]
|