What is the correct syntax for the foreach loop in the Smarty template to iterate over the array assigned in the PHP code?
When using Smarty templates, you can iterate over an array assigned in the PHP code using the {foreach} loop. The correct syntax for the foreach loop in a Smarty template is {foreach from=$array item=item}...{/foreach}, where $array is the array variable assigned in the PHP code and item is the individual element in the array being iterated over. Example:
// PHP code assigning an array to a Smarty template variable
$smarty->assign('myArray', array('apple', 'banana', 'cherry'));
// Smarty template code to iterate over the array
{foreach from=$myArray item=fruit}
{$fruit}
{/foreach}