0

I'm writting PHP tool to edit lighttpd.conf (Lighttpd webserver).

lighttpd.conf style:

variable = value

variable = 1

variable = "value space"

I can work arround with style above but lighttpd.conf also have array style with multi-level array:

variable = ("key" => (
                  "multi-key" => (
                         "subkeya" => "value",
                         "subkeyb" => "value")
                  )
           )

How can I parsing and convert it to array in php ?

Like:

$variable[variable] = "value";
$variable[variable] = array("key" => array("subkey" => "value");
Louis.CLast
  • 424
  • 1
  • 3
  • 15
  • 2
    Complex documents and structural formats are **NOT** meant to be parsed with RegEx. [Tony the Pony will devour you for attempting such things](http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags?rq=1). – Polynomial Apr 23 '13 at 14:22
  • With style 1, I can parsing as line and get value behind "=" symbol, but with array style, I need regex pattern to parsing end of variable value (multiple line). – Louis.CLast Apr 23 '13 at 14:27
  • And what about values that contain `)`, `=`, or escaped `"` characters? How is your regex going to handle those? You need a proper parser, not naive pattern matching. – Polynomial Apr 23 '13 at 14:41

0 Answers0