如何将数组附加到多维数组?当它通过循环时,它需要将数据添加为数组以创建多个数组。它编码为 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
// )
}