Php 需要删除squre括号json_encode(array())
下面是我的代码,它返回json数组,但我需要从响应中删除方括号Php 需要删除squre括号json_encode(array()),php,json,arrays,Php,Json,Arrays,下面是我的代码,它返回json数组,但我需要从响应中删除方括号 $sql = "select user_loginId,user_password from wnl_user where user_loginId='student01' and user_password='123456' and user_status='active'"; //echo $sql;die; $result = mysql_query($sql);
$sql = "select user_loginId,user_password from wnl_user where user_loginId='student01' and user_password='123456' and user_status='active'";
//echo $sql;die;
$result = mysql_query($sql);
$num_rows = mysql_num_rows($result); //function to get number of rows from result
$posts = array();
if($num_rows != 0)
{
if(mysql_num_rows($result)) {
while($post = mysql_fetch_assoc($result)) {
$posts[] = array('status'=>'1','post'=>$post);
}
}
echo json_encode(array('posts'=>$posts));
}
else
{
echo json_encode(array('status'=>"0",'data'=>"No Data Found"));
}
回应是
{"posts":[{"status":"1","post":{"user_loginId":"student01","user_password":"123456"}}]}
我需要删除{“posts”:[这个从开始的方括号中删除,]}也从结尾删除
请帮我解决这个问题使用,您可以删除
数组('posts')
echo json_encode($posts);
而不是
echo json_encode(array('posts'=>$posts));
使用时,您可以删除
数组('posts'
echo json_encode($posts);
而不是
echo json_encode(array('posts'=>$posts));
使用时,您可以删除
数组('posts'
echo json_encode($posts);
而不是
echo json_encode(array('posts'=>$posts));
使用时,您可以删除
数组('posts'
echo json_encode($posts);
而不是
echo json_encode(array('posts'=>$posts));
呃…echo-json\u-encode($posts);
Uh…echo-json\u-encode($posts);
Uh…echo-json\u-encode($posts);