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
PHPMySQL ServerJavaScript

Avatar of undefined
Last Comment
3xtr3m3d

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Guy Hengel [angelIII / a3]

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
3xtr3m3d

ASKER
Thanks a lot, it works!!!
Your help has saved me hundreds of hours of internet surfing.
fblack61