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`
If the attributes inside current has not always returning the same key, you can use this:

```
if(!function_exists("curl_init")) die("cURL extension is not installed");

$url = 'http://services.runescape.com/m=itemdb_rs/api/catalogue/items.json?category=1&alpha=d&page=1';

$ch=curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$r=curl_exec($ch);
curl_close($ch);

$arr = json_decode($r,true);

echo "<table border='1'>";
foreach($arr['items'] as $val)
{
    echo '<tr>';
    echo '<td>'.$val['id'].'</td>';
    echo '<td>'. htmlspecialchars($val['type']) .'</td>';
    echo '<td>'. htmlspecialchars($val['name']) .'</td>';
    echo '<td><img src='. $val['icon'].'></td>';
    foreach($val['current'] as $v){
        echo '<td>'. htmlspecialchars($v) .'</td>';
    }
}
echo "</table>";

```