title: Creating dynamic e-mail template
body: <p>I'm looking for a way to create a good system to push datas into a email template.</p>
  
  <p>I have an array with datas (the number of datas it depends on the number of zones in the email), and a simple html mail template :</p>
  
  <p>Datas: </p>
  
  <pre><code>$mailDatas = array("mail title", "mail body", "mail footer");
  </code></pre>
  
  <p>And a very simple example of what a template should looks :</p>
  
  <pre><code>&lt;div id="mail-container"&gt;
      &lt;div id="mail-header"&gt;{data}&lt;/div&gt;
  
      &lt;img id="some design elements"&gt;
  
  
      &lt;div id="mail-body"&gt;{data}&lt;/div&gt;
  
      &lt;div id="mail-footer"&gt;{data}&lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>What I need is replace the first <code>{data}</code> (it's a string) with the first data of my array <code>$mailDatas[0]</code>, and the second <code>{data}</code> with <code>$mailDatas[1]</code>, [...]</p>
  
  <p>What is the best way to do that? I'm building a function to generate mail body with a template.</p>