note 102323 deleted from function.parse-ini-file by danbrown

[email protected]
Newsgroups php.notes
Message-ID <[email protected]>
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');
?>
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.