如何將數組追加到多維數組?當它通過循環時,它需要將數據添加爲數組以創建多個數組。它編碼爲json併發送到Android手機。如何將數組添加到多維數組?
相關代碼:
$data = array(
"articles" => array(
array(
'id'=> "4335",
'cat'=> "Lifestyle",
'title'=> "Welcome to field and rural life",
'url'=> "http://www.fieldandrurallife.com"
),
array(
'id'=> "4336",
'cat'=> "Lifestyle",
'title'=> "Thank You",
'url'=> "www.thankyou.com"
)
)
);
while($row = mysql_fetch_array($sql))
{
$id = $row["id"];
$cat = $row["category"];
$title = $row["title"];
$url = $row["url"];
// HOW DO I ADD THIS INTO THE ARTICLES ARRAY??
// array(
// 'id'=> $id,
// 'cat'=> $cat,
// 'title'=> $title,
// 'url'=> $url
// )
}
$數據[ '物品'] [] =陣列( 'ID'=> $ ID, '貓'=> $貓, '標題'=> $標題, 'URL'=> $網址); – user20232359723568423357842364