title: Simple templating with str_replace
body: <p>I'm just experimenting first of all.</p>
  
  <p>I just came up with an idea of making my own in a simple way here:</p>
  
  <pre><code>class Template
  {
      function parse($template_file, $braces)
      {
          if(file_exists($template_file))
          {
              $template = file_get_contents($template_file);
  
              foreach($braces as $brace =&gt; $replacement)
              {
                  $brace = trim(strtoupper($brace));
                  $build = str_replace('{' . $brace . '}', $replacement, $template);
              }
  
              echo $build;
          }
          else
          {
              trigger_error('Template file does not exist: ' . $template_file, E_ERROR);  
          }
      }
  }
  </code></pre>
  
  <p>This in order to work:</p>
  
  <pre><code>$template = new Template();
  
  $template-&gt;parse('index_body.html', array('ONE' =&gt; 'one',
                                            'TWO' =&gt; 'two',
                                            'THREE' =&gt; 'three'));
  </code></pre>
  
  <p><strong>index_body.html</strong>:</p>
  
  <pre><code>{ONE}
  {TWO}
  {THREE}
  </code></pre>
  
  <p>The problem is, that it only outputs:</p>
  
  <pre><code>{ONE} {TWO} three
  </code></pre>
  
  <p>It always replaces the last brace, how come not the whole array?</p>