Here\'s what I am trying to accomplish:
function foo($args) {
switch($args[\'type\']) {
case \'bar\':
bar($args[\'data\']); // do something
break;
You could create a JSON-encoded string and use json_decode()
to convert it into a variable. This has syntax very similar to the Python-like syntax you mentioned.
$argstr = '{"type" : "bar", "data" : [1, 2, 3], "data2" : [5, 10, 20]}';
$buildArgs = json_decode($argstr, true);
EDIT: Updated code to accommodate @therefromhere's suggestion.