note 102323 added to function.parse-ini-file

[email protected]
Newsgroups php.notes
Message-ID <[email protected]>
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');
?>
----
Server IP: 64.71.164.2
Probable Submitter: 68.228.136.199
----
Manual Page -- http://www.php.net/manual/en/function.parse-ini-file.php
Edit        -- https://master.php.net/note/edit/102323
Del: integrated  -- https://master.php.net/note/delete/102323/integrated
Del: useless     -- https://master.php.net/note/delete/102323/useless
Del: bad code    -- https://master.php.net/note/delete/102323/bad+code
Del: spam        -- https://master.php.net/note/delete/102323/spam
Del: non-english -- https://master.php.net/note/delete/102323/non-english
Del: in docs     -- https://master.php.net/note/delete/102323/in+docs
Del: other reasons-- https://master.php.net/note/delete/102323
Reject      -- https://master.php.net/note/reject/102323
Search      -- https://master.php.net/manage/user-notes.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.