hello there, How do I print the last element of a one dimensional array? this is my code.
$filename = split("/", $id);
$id returns downloads/application/design/test.exe
thanks
oops! got it
$id = "c:/www/google/com.exe"; $filename = split("/", $id); for ( $cnt=0; $filename[$cnt] != ""; $cnt++) { $filename_final = $filename[$cnt]; } echo $filename_final;
Actually, you can
echo end($filename);
laserlight wrote:Actually, you can echo end($filename);
When working with array pointers, it's definitely helpfull to know about end(), current(), next(), previous(), and reset()... They all move the array pointer around and return the values contained within the elements.