I am having a string in PHP like this-
$str = "Foo var1='Abook' var2='A book'";
I am trying to convert this string to array that will treat the words inside the ''
quotes as single statement (i.e they will ignore the spaces inside ''
quotes).
So my array will look like
Array
(
[0] => "Foo",
[1] => "var1='Abook'",
[3] => "var2='A book'"
)
Note that the array is formed the seperating the string by the space outside ''
quotes, But not inside it.
Can you please give me some good preg function so that I can accomplish this.