【发布时间】:2016-03-30 13:56:18
【问题描述】:
我正在开发一个 IOS 应用程序,对于 API,我将我的请求发送到应该使用 PHP 返回 JSON 数据的 URL 我越来越喜欢了
[{"Child Care":"After Scool,Breakfast Club\n"},{"Child Care":"Breakfast Club"}]
但我想得到喜欢
[{
"Childcare":[
"All of Childcare",
"After school",
"Breakfast Club"
]}
我的代码是
<?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);
?>
【问题讨论】:
-
在这里发布你得到的东西
-
[{"Child Care":"After Scool,Breakfast Club\n"},{"Child Care":"Breakfast Club"}]