Link to home
Create AccountLog 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
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of 3xtr3m3d
3xtr3m3d

ASKER

Thanks a lot, it works!!!