Just want to note that the same thing happens for file() calls, but you can supply a second argument like the following to prevent that,
<?php
$files = file("my.log", FILE_IGNORE_NEW_LINES);
I know this is a late reply, but often there's a pesky newline character in your variable sent to filemtime() or other functions.
I see this a lot when globbing. The code below removes those line endings. Both \r and \n.
$files = glob("*.jpg");
foreach ($files as $file) {
$file = preg_replace("/(\r|\n)/", "", $file);
$mtime = date("Y-m-d H:i:s", filemtime($file));
print($mtime . "\n");
}
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.