I was wondering if anyone here could help me. I have the following string:
$str = 'unit1(field1,field2,field3),unit2(field4,field5,field6)';
I am trying to parse this string to create the following array:
array(
'unit1' => array('field1', 'field2', 'field3')
'unit2' => array('field4', 'field5', 'field6')
)
I am pretty hopeless with regex so I am not even sure where to start with this.
Thanks
unit2?preg_matchandpreg_match_allon the PHP docs. Once you read all that try to build your own solution and come back with the code that failed and somebody might help.[{"unit":"unit1", "fields":["field1","field2"]},...]andjson_decode($str)?