note 19160 added to function.sizeof

From: Date: Mon, 18 Feb 2002 14:07:25 +0000
Subject: note 19160 added to function.sizeof
Groups: php.notes 
Request: Send a blank email to php-notes+get-26741@lists.php.net to get a copy of this message
I can't seem to find a function to get the last key value of an array. (come to use when you have gaps in your array that makes count/sizeof unreliable) I found a sollution that may not be perfect, but it works :) function lastKeyValue($array) { while(list($key, $val) = each($array)) $iArraySize = $key; return $iArraySize; } $myArray = array(0 => "foo", 3 => "bar"); echo "Last key value: " . lastKeyValue($myArray); -- http://www.php.net/manual/en/function.sizeof.php http://master.php.net/manage/user-notes.php?action=edit+19160 http://master.php.net/manage/user-notes.php?action=delete+19160 http://master.php.net/manage/user-notes.php?action=reject+19160

« previous php.notes (#26741) next »