0
我使用PHP文件檢索從MySQL服務器的數據改變mysqli_query輸出格式,輸出是:需要通過PHP文件
Array ([0] => Abbasya [1] => Alex Auto [2] => Alex Post [3] => Banisweif [4] => Nasr City [5] => Ramsis TE [6] => Smart Village).
我需要改變輸出到像下面的我需要在我的android應用程序中將字符串轉換爲字符串[]。
需要輸出(只打印值):
"Abbasya", "Alex Auto", "Alex Post", "BaniSweif", "Nasr City", "Ramsis TE", "Smart Village"
什麼是對下面的PHP代碼所需要的改變來產生所需的輸出
<?php
require "init.php";
$query = mysqli_query($con,"SELECT core_site FROM core_sites");
$coresites = [];
while($row = mysqli_fetch_assoc($query)){
$coresites[] = $row['core_site'];
}
print_r($coresites);
?>
的支持非常感謝:)
你可以試試implod轉換數組爲字符串,或者你可以使用json_encode()爲Android Web服務 –
檢查這個答案http://stackoverflow.com/questions/5528097/how-can-i-print-all-the-values -of-an-array –