Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Thanked 0 Times in 0 Posts

    Case Sensitivity


    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:

    $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?


  • #2
    Super Moderator
    Join Date
    May 2002
    Perth Australia
    Thanked 101 Times in 99 Posts
    nothing straightforward that I can think of ...you could load the files into an array ... if you have >=4.3.0 use glob();

    PHP Code:
    foreach (glob("/home/user/path/*" GLOB_ONLYDIR ) as $dir) { 
    strtoupper$dir ) == strtoupper$search_string ) ){
    "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 ??
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)


    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts