Link to home
Start Free TrialLog in
Avatar of 3xtr3m3d
3xtr3m3d

asked on

php array help

Hi

This is the array im working on
$x = 0;
while($row = mysql_fetch_object($sql_result) )
{
$json[$x] = array    (
   $json[$x] = array    (   
                            'id' => $row->fid,
                            'rel' => $row->ftype,							
                        ),
			
			"data" => $row->ftitle,
			"state" => ""
);  
$x++;

}
echo  json_encode($json);

Open in new window


this out put is like

[{"0":{"id":"3","rel":"file"},"data":"file1.doc","state":""},{"0":{"id":"4","rel":"file"},"data":"filetest.doc","state":""}]

Open in new window


i have no idea why "0" appear on output.

is there way to replace "0" with "attr" ?

any help would be great.

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of 3xtr3m3d
3xtr3m3d

ASKER

Thanks a lot, it works!!!