note 19160 deleted from function.sizeof by jimw

From: Date: Wed, 03 Apr 2002 18:57:12 +0000
Subject: note 19160 deleted from function.sizeof by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-28556@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);

« previous php.notes (#28556) next »