Page 1 of 1

parse_ini_file() case sensitive problem.

Posted: Mon Jul 02, 2007 2:00 pm
by 303tech
i would like the command to pick up with no case sensitivity. Right now if the file is not exactly in the case it will not find it.

ex: parse_ini_file('file.ini')
parse_ini_file('FiLe.INI')

how can i do this?

also, would like it to do the same with the parse

$id=$ini['id'];
$id=$ini['ID'];

Posted: Mon Jul 02, 2007 2:04 pm
by Oren
File names are case sensitive on *nix based systems, and I believe that's how it should be (tell that to the guys on M$ :P).

Edit: strtolower() *might* be of interest (based on your specific needs - which you didn't tell us).

Posted: Mon Jul 02, 2007 2:54 pm
by 303tech
well basically, the ini file on the users computer is sometimes named with caps and sometimes not....id like it to pick up on either. I want the parse to look for any case of file.ini

Posted: Mon Jul 02, 2007 3:08 pm
by superdezign
Do a file_exists on every combination...? :P

Posted: Mon Jul 02, 2007 3:16 pm
by volka
Or use glob() to find all ini files.

Code: Select all

<?php
$iniFiles = glob('*.{i,I}{n,N}{i,I}', GLOB_BRACE);
print_r($iniFiles);

Posted: Mon Jul 02, 2007 3:47 pm
by RobertGonzalez
Or ask the user to name their ini file with lower case letters.

Posted: Mon Jul 02, 2007 5:42 pm
by 303tech
volka wrote:Or use glob() to find all ini files.

Code: Select all

<?php
$iniFiles = glob('*.{i,I}{n,N}{i,I}', GLOB_BRACE);
print_r($iniFiles);
how would i use that with
$ini = parse_ini_file("$id/file.ini");