I need a preg function which do the following job for following string-
string = {my_special_shortcode_name var1='some_var1' var2='some_var2' var3='some_var3'}
and the extracted string must look like-
Array( 'var1' => 'some_var1',
'var2' => 'some_var2',
'var3' => 'some_var3'
)
Obviously I need the some pref function, but I have tried separating the string based on space formatting, but when I include spaces in any parameter of var1/var2/var3, for ex-
When I given this input instead-
string = {my_special_shortcode_name var1='some var1' var2='some_var2' var3='some_var3'}
NOTE THE SPACE IN SOME VAR1 (INSTEAD OF SOME_VAR1)
The following output is obtained-
Array( 'var1' => 'some',
'var1' => 'var2',
'some_var2' => 'var3'
)
So I need a function which separate the string based on space outside the ""
, not the space within ""
.
Any idea how?
EDIT: I have successfully extracted the string into array. Problem lies in URL containing '?' which makes the separate string within "". So now, I need someone to suggest how to escape '?' and separate string into array?