What potential issues can arise when using Smarty for templating in PHP, especially in relation to arrays being displayed before the template?

When using Smarty for templating in PHP, one potential issue that can arise is when arrays are displayed before the template is rendered. This can lead to unexpected output or errors in the template. To solve this issue, make sure to assign the array data to the template variables before displaying the template.

<?php
require_once('smarty/libs/Smarty.class.php');

$smarty = new Smarty();

// Assign array data to template variables
$data = array('name' => 'John Doe', 'age' => 30);
$smarty->assign('data', $data);

// Display the template
$smarty->display('template.tpl');
?>