i have a function which brings me some data from database and posts to my client. At the moment it sends data as a normal array(output is something like MyArray (a,b,c,d..)), but i want it to be MyArray (a(b,c,d)).. As like Castegory(Name, ID, Order..).. Can anyone please Help..Here is my code for already used version
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;
}
EDIT A little öore detail please.. when i parsed this i get something like this:
"Vaule"( "Key1": "Value1" "Key2": "Value2" .
But what i want is omething like
`"Category0":( "Key1": "Value1", "Key2": "Value2" . )
"Category1":( "Key1": "Value1", "Key2": "Value2" . )..`
How can i send a multidimentional array with key-value pairs?
mysql_*
functions in new code. They were removed from PHP 7.0.0 in 2015. Instead, use prepared statements via PDO or MySQLi. See Why shouldn't I use mysql_* functions in PHP? for more information.