note 102323 deleted from function.parse-ini-file by danbrown
| From: | danbrown@php.net | Date: | Tue, 08 Feb 2011 18:40:18 +0000 |
| Subject: | note 102323 deleted from function.parse-ini-file by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-176790@lists.php.net to get a copy of this message | ||
Note Submitter: bobvin at pillars dot net
----
The supposedly php-compatible browscap.ini file available from browser.garykeith.com will not parse,
because some of the section keys contain semicolon (;) or single-quote (') characters.
To avoid this, simply backslash-escape the offending characters:
<?php
$in = fopen('http://browsers.garykeith.com/stream.asp?PHP_BrowsCapINI',
'r');
$out = fopen('browcap.ini', 'w');
fwrite(
$out,
preg_replace(
array(
"/(?<![;\n])([;'])/",
'/\A\\\\/'
),
array(
'\\\\$1',
''
),
fread($in)
)
);
fclose($in);
fclose($out);
$parsed = parse_ini_file('browscap.ini');
?>