I have this string
$s = 'Yo be [diggin = array("fruit"=> "apple")] scriptzors!';
which then gets checked by
$matches = null;
preg_match_all('/\[(.*?)\]/', $s, $matches);
var_dump($matches[1]);
but what I want it to do is the following, it should return the following
print "yo be";
$this->diggin(SEND ARRAY HERE);
print "scriptzors!";
EDIT to show issue with below answer
$s = 'Yo be [diggin = array("fruit"=>"apple")] scriptzors!';
$matches = null;
preg_match_all('/\[(.*?)\]/', $s, $matches);
$var = explode(' = ', $matches[1]);
print $var[0]; //THIS DOES NOT PRINT
You’re sort of close. You can
explodethe string with=but with spaces included around the=. Then the first element would be the function name, in this casedigginand the second element would be the array but as a string. You’ll need toevalthat one so that it’ll be a proper array data type.As an alternative, you can also modify the regex so that you don’t have to call
explode.Either way, you’ll want to make sure that you sanitize the user input because
evalcan be evil.