SMARTY: check if array index exists?

Hi All,

I am using SMARTY templates in my PHP app. I am getting NOTICE warnings that array indexes don’t exist if I have an uninstantiated SMARTY array variable. This most often happens when I run a database query that produces no results, so when I loop through the resultset in SMARTY, nothing is there. Take the following example:

{section name=n_count loop=$a_resultset start=0}
<br />My Name: {$a_resultset[n_count].name}
<br />My Eamil: {$a_resultset[n_count].email}

The section won’t loop of course, however, the SMARTY engine still parses the indexes within (here name and email) and triggers PHP NOTICE warnings.
I would like to clean up my code and eliminate these warnings. What can I in this regard?

Thanks for all your help!

I don’t know about SMARTY, but typically this is what I do…

  //execute code here

// also works with isset($array)

If it’s not set it won’t try to run.