Reputation: 281
I have following filename "test.mkv" from an array and following string "test.mkv".
PHP says it not equal if I do this:
$dir = '/folder';
$filesarray = scandir($dir);
if($filesarray[0] == $string)
Whats wrong?
Upvotes: 0
Views: 178
Reputation: 23675
$found = in_array($string, scandir("/folder"));
$found
will be true
if any file matches your $string
content. Usually indices 0
and 1
contain respectively .
and ..
so I doubt that your check can work...
If your intention is just to check if a given file exists, use this:
file_exists("folder/$string")
Upvotes: 2