I have this line
comment=Accept established chain=forward connection-state=established
And I need to parse it to array. Using explode("=") doesn't work as expected. I get:
array(4) {
[0]=>
string(7) "comment"
[1]=>
string(24) "Accept established chain"
[2]=>
string(24) "forward connection-state"
[3]=>
string(11) "established"
}
I tried playing with regex( I suck at it badly). but managed to somehow got to 50%:
preg_match_all("/[([a-zA-Z\-]+=]?/", $line, $result)
which returns:
array(1) {
[0]=>
array(3) {
[0]=>
string(8) "comment="
[1]=>
string(6) "chain="
[2]=>
string(17) "connection-state="
}
}
So it's half way. Now I don't know how to get the string after the "=" part for each line.