Jump to content

using end() to get last file name out of array.


denoteone

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.