Given a string with attribute / value pairs, e.g.
attr1="some text" attr2 = "some other text" attr3= "some weird !@'#$\"=+ text"
the goal is to parse it and output an associative array, in this case:
array('attr1' => 'some text',
'attr2' => 'some other text',
'attr3' => 'some weird !@\'#$\"=+ text')
Notice the inconsistent distance around the equal signs, the escaped double quote in the input, and the single quote in the output file.
source
share