I can create simple json objects like this:
$d = array(\'item\' => \"$name\" ,\'rate\' => \"$rating\");
But what if I want to build an ar
What you can do is create a php array dynamically as you want then covert it into a json array as below.
$json_array = json_encode($array);
Keep in mind that what you have provided is not a json array