How can I get the last value from an array with unknown length?
Thanks.
Hi,
<? $intLen = count($array); $lastValue = $array[$intLen]; ?>
that should save the last value in the var 'lastValue'.
Hope it could help
regards ali
Hmm...
$startfive = split (" ", $start[5]); $intLen = count($startfive); $lastValue = $startfem[$intLen]; echo "'$lastValue'";
This give me the result of '' and not the little word it should be, any suggestions?
in the code it says "$lastValue = $startfive[$intLen];" so that is not the error just my typing 🙂
surely that should be
$lastValue = $array[$intLen-1];
<? $array = array ('one', 'two', 'three'); rsort ($array); $last_value = reset ($array); ?>
this will return "three"