2
IM在我的数据库表中检索一些数据,比转换成JSON,但我需要在我的PHP循环的Json编码多维阵列格式
["postcode"=>"townName"...]
使用这structire一个数组,但取而代之的是给我
["postcode=>townName"...]
我的代码:
$sql = "SELECT * FROM uk_postcodes";
$result = mysqli_query($connection, $sql) or die("Error " . mysqli_error($connection));
$dname_list = array();
while($row = mysqli_fetch_array($result))
{
$dname_list[] = $row['postcode']."=>".$row['town'];
}
echo json_encode($dname_list);