I need to find the largest height & width values in a directory. I've tried to use:
if ($handle = opendir('path/to/image')) {
while (false !== ($file = readdir($handle))) {
if (preg_match('/(jpg|gif|png)/', $file )) {
$images[] = $file;
list($width, $height) = getimagesize('path/to/image/'.$file);
$max_w = max(array($width));
$max_h = max(array($height));
}
}
closedir($handle);
}
$max_w
returns the last image in an arrrays size, as it does in a foreach statement.
This works: $max_w = max(array(135, 100, 150, 101));
, but it reads as a string above.
How do I get the width into an array so I can get the max value?