简体   繁体   中英

PHP4 - Parse ini

I'm doing this on an old NAS drive which has php embeded and is running PHP4.

parse_ini_file is supported, but I can't create an array of values within the returned results.

The following works :

[first_section]
one = 1
five = 5
animal = BIRD

[second_section]
path = "/usr/local/bin"
URL = "http://www.example.com/~username"

[third_section]
phpversion[] = "5.0"
phpversion[] = "5.1"
phpversion[] = "5.2"
phpversion[] = "5.3"

// Parse with sections
$ini_array = parse_ini_file("sample.ini", true);
print_r($ini_array);

but the third section just returns :

[third_section] => Array
        (
            [phpversion[]] => 5.3
        )

Not all of the values.

Am I doing this wrong or is it due to PHP 4 ?

Any alternative methods ?

Yes, this is due to PHP4. See http://3v4l.org/DMEud

The output starting from PHP 5 will give the third section as shown in the manual, while previous version will show the behavior you encounter.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM