note 24804 added to function.end

From: Date: Wed, 28 Aug 2002 22:34:37 +0000
Subject: note 24804 added to function.end
Groups: php.notes 
Request: Send a blank email to php-notes+get-35950@lists.php.net to get a copy of this message
If you need to get a reference on the first or last element of an array, use these functions because reset() and end() only return you a copy that you cannot dereference directly: function first(&$array) { if (!is_array($array)) return &$array; if (!count($array)) return null; reset($array); return &$array[key($array)]; } function last(&$array) { if (!is_array($array)) return &$array; if (!count($array)) return null; end($array); return &$array[key($array)]; } -- http://www.php.net/manual/en/function.end.php http://master.php.net/manage/user-notes.php?action=edit+24804 http://master.php.net/manage/user-notes.php?action=delete+24804 http://master.php.net/manage/user-notes.php?action=reject+24804

« previous php.notes (#35950) next »