parse_ini_file() case sensitive problem.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
303tech
Forum Commoner
Posts: 31
Joined: Sun Mar 11, 2007 3:25 pm

parse_ini_file() case sensitive problem.

Post 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'];
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Post 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).
303tech
Forum Commoner
Posts: 31
Joined: Sun Mar 11, 2007 3:25 pm

Post 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
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

Do a file_exists on every combination...? :P
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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);
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Or ask the user to name their ini file with lower case letters.
303tech
Forum Commoner
Posts: 31
Joined: Sun Mar 11, 2007 3:25 pm

Post 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");
Post Reply