#33981 [NEW]: parse_ini_file and non-alphanumerics
| From: | mdc at hotmail dot co dot uk | Date: | Wed, 03 Aug 2005 15:14:23 +0000 |
| Subject: | #33981 [NEW]: parse_ini_file and non-alphanumerics | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-82892@lists.php.net to get a copy of this message | ||
From: mdc at hotmail dot co dot uk
Operating system: WinXP/Win200
PHP version: 5.0.4
PHP Bug Type: Variables related
Bug description: parse_ini_file and non-alphanumerics
Description:
------------
When using the parse_ini_file function to parse through a specific section
of an ini file ("Applications Packages") the parsing stops whenever the
following characters are present in the key()[]
Example of ini file:
--
[Applicantions Packages]
Winamp.ini=INSTALLED
Macromedia Shockwave Player 10.ini=INSTALLED
Windows (test) Media Player 10 Series.ini=INSTALLED
Office XP Security Patch KB830346.ini=INSTALLED
Acrobat Reader 6.0.ini=INSTALLED
The desired entries in the ini file are output'd to screen as expected
until the parsing stops at line 3 and the browser shows:
"Warning: Error parsing \\server1\file.ini on line 3 in
c:\Inetpub\wwwroot\test\results.php on line 85"
(Code snippets included in the next section).
I've tried writing additional code to copy the contents to a temporary
file, and replace the "illegal" characters with blank spaces, but thats
quite inefficent as the ini file can be several hundred lines long and I
only need to parse the 20 or 30 lines within it.
I've read similar posts regarding this problem, but they're said to be
fixed.
Reproduce code:
---------------
Line 85 of the code is:
$settings_array = parse_ini_file($inifile, TRUE);
Also relevant, looking for the section "Applications Packages"
--
$applications = array_filter($applicationsArray['Applications Packages'],
"isInstalledApplications");
--
This is the value to be matched to the keys.
--
function isInstalledApplications($var) {
return($var == 'INSTALLED' );
}
--
Output code. $station is part of the ini file name, which makes up
$inifile eg, station1.ini. Could be tidier, I know ;-)
--
<?php
foreach($applications as $key => $value)
{
$station = str_replace('.ini', '', $key);
$key = str_replace('.ini', '', $key);
?>
--
Expected result:
----------------
--
The following items are installed on <workstation name here>
Winamp
Macromedia Shockwave Player 10
Windows (test) Media Player 10 Series
Office XP Security Patch KB830346
Acrobat Reader 6.0
--
Actual result:
--------------
--
The following items are installed on <workstation name here>
"Warning: Error parsing \\server1\file.ini on line 3 in
c:\Inetpub\wwwroot\test\results.php on line 85"
Winamp
Macromedia Shockwave Player 10
--
--
Edit bug report at http://bugs.php.net/?id=33981&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=33981&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=33981&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=33981&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=33981&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=33981&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=33981&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=33981&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=33981&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=33981&r=support
Expected behavior: http://bugs.php.net/fix.php?id=33981&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=33981&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=33981&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=33981&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=33981&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=33981&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=33981&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=33981&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=33981&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=33981&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=33981&r=mysqlcfg