I can create simple json objects like this:
$d = array(\'item\' => \"$name\" ,\'rate\' => \"$rating\");
But what if I want to build an ar
Why not create your array as you just have done but then pass the array through json_encode?
json_encode
If you want a multi-dimensional array, try
$array[] = array("key1" => value1, "key2" => value2);