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`
Try this one.

First check if the array is empty or not. If the array is empty it will through error because you are passing an associative array and in the first loop there is no close for tr tag.

```
if(!empty($arr))
{
     //for loop
}
else
{
    echo "Array empty";
}

```