KenHorse Posted April 18, 2020 Share Posted April 18, 2020 I have a Windows-style ini file that contains entries as such: [Timers] Timer(1)=50 Timer(2)=30 Timer(3)=20 The entries represent an array of 3 different timers Apparently parse_ini_file can't deal with the () format. Is there any way to use this format ini file without having to change how arrays are designated? Quote Link to comment https://forums.phpfreaks.com/topic/310610-using-parse_ini_file-to-parse-an-ini-file-with-array-type-entries/ Share on other sites More sharing options...
Barand Posted April 18, 2020 Share Posted April 18, 2020 8 minutes ago, KenHorse said: Apparently parse_ini_file can't deal with the () format When it comes to it, no part of php uses () format for arrays. try [Timers] Timer[1]=50 Timer[2]=30 Timer[3]=20 with $timers = parse_ini_file('mytimers.ini', 1); echo '<pre>', print_r($timers, 1), '</pre>'; giving Array ( [Timers] => Array ( [Timer] => Array ( [1] => 50 [2] => 30 [3] => 20 ) ) ) Quote Link to comment https://forums.phpfreaks.com/topic/310610-using-parse_ini_file-to-parse-an-ini-file-with-array-type-entries/#findComment-1577006 Share on other sites More sharing options...
KenHorse Posted April 18, 2020 Author Share Posted April 18, 2020 Thanks. It sees them now (Not a big deal to replace the () with [] after all....) Quote Link to comment https://forums.phpfreaks.com/topic/310610-using-parse_ini_file-to-parse-an-ini-file-with-array-type-entries/#findComment-1577009 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.