I have string
$argsInString = '"%s hello", \'%s world\', $foo->bar("anything", array(\'foo\' => 5 , \'bar\' => $a)),5, foo($s) ,$foo';
And I want convert to array like this:
$argsInArray = array('"%s hello"', '\'%s world\'', '$foo->bar("anything", array(\'foo\' => 5 , \'bar\' => $a))', '5', 'foo($s)', '$foo');
I try anything like this:
eval('$argsInArray = array(' . $argsInString . ');');
but this execute variables.
Could you help me how create $argsInArray from $argsInString?
EDIT: If it succeed to write a regular expression that would clothed individual parameters, using a single quote ('), in the string, then the eval work as described above.
Or could you write regular expression preg_match_all('...', $argsInString, $argsInArray); this is best.
eval
in your code, you're doing something wrong. Where does$argsInString
come from and what exactly are you going to be using the output for?