Question: I want save the output of an array in a hidden div in smarty tpl. I used `{$product|@print_r}` to do that. But I want that array to be serialized. Is there any way to get serialized `$product` array. Pls help.

Answer: 
this is better written as 

```
 echo '<td>'. htmlspecialchars($val['current']['price']) .'</td></tr>';     

```

your were trying to iterate `$arr` which is the outter array which doesn't contain a element called `current`
```
$json_str='   {
   "total": 1,
   "items": [
      {
         "icon": "http://services.runescape.com/m=itemdb_rs/4173_obj_sprite.gif?id=11230",
         "icon_large": "http://services.runescape.com/m=itemdb_rs/4173_obj_big.gif?id=11230",
         "id": 11230,
         "type": "Ammo",
         "typeIcon": "http://www.runescape.com/img/categories/Ammo",
         "name": "Dragon dart",
         "description": "A deadly throwing dart with a dragon tip.",
         "current": {
            "trend": "neutral",
            "price": 184
         },
         "today": {
            "trend": "neutral",
            "price": 0
         }
      }
   ]
}';
$arr = json_decode($json_str,true);
// this $arr contains array with-in array so there is no direct access to 
// 'Price' its either inside current or today so access  them accordingly like 
$arr['current']['price'];
//or
$arr['today']['price'];

```