0

When using parse_ini_file, it will attempt to read and understand the ini file. I'm looking for a solution that will read the file, place it into arrays much like parse_ini_file does, however I don't want it to get to the special characters in my ini file and spit an error that it can't parse them. Could anyone point me in the right direction?

ini file for reference:

[IMPORT]
email=email@thisisanemail.com
location=
Description=Order Form
name=*.xls*
matrixfile=
matrix_field=
matrix_disc_type_column=
matrix_disc_percentage_column=
fixed=XLS
separator=|
RowTerminator=
headerrows=13
footerrows=0
maxexcelcolumns=7

If I parse this, it gets stuck on the seperator "|" but I need that there.

Ridai
  • 179
  • 1
  • 8
  • `file_get_contents` will get the contents of a file.. http://php.net/manual/en/function.file-get-contents.php or `fread`...http://php.net/manual/en/function.fread.php – chris85 Aug 05 '15 at 16:02
  • can you quote the separator? `separator="|"` – Ray Aug 05 '15 at 16:03
  • Thanks. How would I turn this into an array with that? Explode? How would I specify a delimiter for that? – Ridai Aug 05 '15 at 16:03
  • I have about a hundred of these ini files, and I'm not too sure if quoting the ini would affect my other piece of software sadly! – Ridai Aug 05 '15 at 16:04
  • Oh if you want an array use `file`, http://php.net/manual/en/function.file.php – chris85 Aug 05 '15 at 16:04
  • Oh interesting, I'll have an experiment with `file`, thanks! – Ridai Aug 05 '15 at 16:06

1 Answers1

2

If you use parse_ini_file with the scanner_mode parameter to specify INI_SCANNER_RAW, then option values will not be parsed (see https://www.php.net/manual/en/function.parse-ini-file.php).

Dharman
  • 30,962
  • 25
  • 85
  • 135