I'm developing an IOS app, and for the API I'm sending my requests to a URL that should return JSON data with PHP I am Getting like
[{"Child Care":"After Scool,Breakfast Club\n"},{"Child Care":"Breakfast Club"}]
But I want to get like
[{
"Childcare":[
"All of Childcare",
"After school",
"Breakfast Club"
]}
My code is
<?php
session_start();
$connection=mysqli_connect('localhost','root','','testing') or die(mysqli_error());
$sql="select `Child Care` from Activity_type ";
$result = mysqli_query($connection,$sql) or die("Error in Selecting " . mysqli_error($connection));
$emparray=array();
while($row =mysqli_fetch_assoc($result)){
array_push($emparray,$row);
}
header('Content-Type: application/json');
echo json_encode($emparray);
?>