i want to extract parameter like exist in annotation
i have done this far
$str = "(action=bla,arg=2,test=15,op)";
preg_match_all('/([^\(,]+)=([^,\)]*)/', $str, $m);
$data = array_combine($m[1], $m[2]);
var_dump($data);
this gives following out put
array (size=3)
'action' => string 'bla' (length=3)
'arg' => string '2' (length=1)
'test' => string '15' (length=2)
this is ignoring op (but i want it having null or empty value)
but i want to improve this so it can extract these also
- (action='val',abc) in this case value inside single quote will assign to action
- (action="val",abc) same as above but it also extract value between double quote
- (action=[123,11,23]) now action action will contain array 123,11,23 (this also need to extract with or without quotation)
i don't want complete solution(if you can do it then most welcome) but i need at least first two
EDIT
(edit as per disucssion with r3mus) output should be like
array (size=3)
'action' => string 'bla' (length=3)
'arg' => string '2' (length=1)
'test' => string '15' (length=2)
'op' => NULL