Skip to content

Instantly share code, notes, and snippets.

@salaros
Forked from hubgit/file-exists-ci.php
Created July 3, 2018 21:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save salaros/ed527cf3999fddb098d146fcf265c4a8 to your computer and use it in GitHub Desktop.
Save salaros/ed527cf3999fddb098d146fcf265c4a8 to your computer and use it in GitHub Desktop.
Check if a file exists, with case-insensitive file name.
<?php
function file_exists_ci($file) {
if (file_exists($file))
return $file;
$lowerfile = strtolower($file);
foreach (glob(dirname($file) . '/*') as $file)
if (strtolower($file) == $lowerfile)
return $file;
return FALSE;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment