What would be php code to get this json?
{ "data": "w-file1",
"attr": { "rel" : "file"}
}
I am getting PHP Parse error: syntax error, unexpected T_DOUBLE_ARROW error for
$file = ("data" => "w-file1","attr" => ("rel" => "file"));
echo json_encode($file);
$file needs to be an array as does the
attrkey:Of course, you could inline it:
Or, there is the OOP approach: