我有这个PHP脚本应该输出一个json数组,它做到了但我的json数组以[[]开头,为什么这两个额外的方括号[]?
$servername = "localhost";
$username = "root";
$password = "password";
$dbname = "mydb";
$conn = mysql_connect($servername, $username, $password,$dbname);
$result = mysql_query("select * from mydb.mytable" )
or die(mysql_error());
//create an array
$emparray[] = array();
while($row =mysql_fetch_assoc($result))
{
$emparray[] = $row;
}
$object = $emparray;
echo json_encode($object) ;