I\'m trying to fetch all results form mysql table and convering to Json format. Each row may contain a common column value(movie_name). I want to group results by that common fi
$json_arr = array("movies"=>array());
foreach ($slots as $slot) {
$json_arr['movies'][$slot["movie_name"]]['movie_name'] = $slot["movie_name"];
$json_arr['movies'][$slot["movie_name"]]['slots'][] = array (
"slot_id" => $slot["slot_id"],
"screen_id" => $slot["screen_id"],
"time" => $slot["time"],
"price" => $slot["price"]
);
}