troubleshooting Question

php array help

Avatar of 3xtr3m3d
3xtr3m3d asked on
PHPMySQL ServerJavaScript
2 Comments1 Solution194 ViewsLast Modified:
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
Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros