bluetrack
15 Nov 2007, 1:42 AM
Hi!, when i try to add "item1" to the array i can't get the data right with json_encode
$arr = array();
$rs = mysql_query($sql);
while($obj = mysql_fetch_object($rs)) {
$arr[] = $obj;
}
$arr[] = array("item1" => "1");
echo ''.json_encode($arr).''; without item1
[{"id":"39","uName":"Christian"}]
with item1
[{"id":"39","uName":"Christian"},{"item1":"1"}]
how do i do to get the result like this???:
[{"id":"39","uName":"Christian","item1":"1"}]
$arr = array();
$rs = mysql_query($sql);
while($obj = mysql_fetch_object($rs)) {
$arr[] = $obj;
}
$arr[] = array("item1" => "1");
echo ''.json_encode($arr).''; without item1
[{"id":"39","uName":"Christian"}]
with item1
[{"id":"39","uName":"Christian"},{"item1":"1"}]
how do i do to get the result like this???:
[{"id":"39","uName":"Christian","item1":"1"}]