...

View Full Version : Case Sensitivity



holty
01-09-2004, 08:40 AM
Hi,

I have a script to check to see if a directory exists on the webserver. I am passing in the folder name and seeing if it exists. If a user types in the correct name for a folder but in the wrong case I would like my code to still return that the directory exists....

here is my code:

[php]
<?php
$path = 'images'; //works
$folder = 'bananas';
$test = $path.'/'.$folder;

print '<br>Path to Directory = ' . $test;

if (is_dir ($test)) {
print "<br><br>++Dir exists" . '[' . $test .']';
} else {
print "<br><br>--Dir doesn't exist" . '[' . $test .']';
}
?>

At the moment it will return "Dir doesn't exist' as the folder is named 'Bananas' - I would like it to be case sensitive....

Any ideas on how to achieve this?

Thanks

firepages
01-09-2004, 12:48 PM
nothing straightforward that I can think of ...you could load the files into an array ... if you have >=4.3.0 use glob();




<?php
foreach (glob("/home/user/path/*" , GLOB_ONLYDIR ) as $dir) {
if( strtoupper( $dir ) == strtoupper( $search_string ) ){
echo "Found $dir";break;
}
}
?>


note that GLOB_ONLYDIR flag seems not to work for me on 4.3.4 on win32 , though on win32 directories and paths should be case-insensitive anyway ??



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum