我有一个功能,可以从数据库中获取一些数据并将其发布给我的客户。目前它以普通数组的形式发送数据(输出类似于 MyArray (a,b,c,d..)),但我希望它是 MyArray (a(b,c,d)).. 就像Castegory(姓名,ID,订单..)..任何人都可以帮忙..这是我已经使用的版本的代码
public function get_button_template()
{
$this->q = "SELECT * FROM button_template ORDER BY order_number ASC";
$this->r = mysql_query($this->q);
if(mysql_num_rows($this->r) > 0)
{
while($this->f = mysql_fetch_assoc($this->r))
{
$this->buttons[$this->i]["ID"] = $this->f["ID"];
$this->buttons[$this->i]["name"] = $this->f["button_name"];
$this->buttons[$this->i]["category"] = $this->f["button_category"];
$this->buttons[$this->i]["order_number"] = $this->f["order_number"];
$this->i++;
}
}
return $this->buttons;
}
请编辑一些详细的细节..当我解析这个时,我得到这样的东西:
"Vaule"( "Key1": "Value1" "Key2": "Value2" .
但我想要的是类似的东西
`"Category0":( "Key1": "Value1", "Key2": "Value2" . )
"Category1":( "Key1": "Value1", "Key2": "Value2" . )..`
如何发送带有键值对的多维数组?