denoteone Posted April 29, 2010 Share Posted April 29, 2010 Ia m building an array like so $images_new = array(); while (($file = readdir($dh)) !== false) { if($file != '.' && $file != '..' && !is_dir($dir.$file)){ $images_new[] = array('name' => $file, 'size' => filesize($dir.$file)); } } Now I want to get the last value of the last 'name' I thought it was something like: $lastname = end($images_new['name']); echo $lastname; the error I am getting is: Warning: end() [function.end]: Passed variable is not an array or object in Link to comment https://forums.phpfreaks.com/topic/200169-using-end-to-get-last-file-name-out-of-array/ Share on other sites More sharing options...
Alex Posted April 29, 2010 Share Posted April 29, 2010 $last = end($images_new); echo $last['name']; Link to comment https://forums.phpfreaks.com/topic/200169-using-end-to-get-last-file-name-out-of-array/#findComment-1050535 Share on other sites More sharing options...
denoteone Posted April 29, 2010 Author Share Posted April 29, 2010 Great Thanks AlexWD! Link to comment https://forums.phpfreaks.com/topic/200169-using-end-to-get-last-file-name-out-of-array/#findComment-1050537 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.