[FX.php List] Get first and last array element
DC
dan.cynosure at dbmscan.com
Thu Dec 15 13:59:38 MST 2005
Here's a good way to get the first and last elements from an array
without disturbing the array. And unlike current() it ensures that you
actually get the first value rather than assuming it will be the first.
Enjoy.
// end() gets the last array element
// NB. it moves the pointer, you should always
// follow this with a reset()
$last_rec=end($FXresult['data']);
// reset() resets pointer to the first element and returns it
$first_rec=reset($FXresult['data']);
dan
More information about the FX.php_List
mailing list