Possible Duplicate:
encode json using php?
$hello_world = $this->session->all_userdata();
foreach($hello_world as $key=>$product_id)
{
$query['products'] = $this->Global_products->globalFindProductsViewed($product_id);
foreach($query['products'] as $product)
{
$ryan[] = $product->name;
}
}
foreach($ryan as $r)
{
echo json_encode(array($r));
}
The output then looks like this: ["Alpine 50W x 4 Apple® iPod®-Ready In-Dash CD Deck"]
I know I cant access this with JavaScript. Can someone suggest how I can make this work?