Replace 'keys' in file with DB data
<p>Currently I have a the following way of retrieving data from my DB:</p>

<pre><code>$school-&gt;get('studentCount');
</code></pre>

<p>I required a shortcut to access these fields within the page and so came up with a format like this:</p>

<pre><code>&lt;p&gt;Blah blah blah [[studentCount]]&lt;/p&gt;
</code></pre>

<p>I have output buffering turned on but just need an easy way of replacing that key ('[[field-name]]') with its corresponding data from the DB.</p>

<p>If it was just one field I could do a str_replace on the output like this:</p>

<pre><code>str_replace($output, '[[studentCount]]', $school-&gt;get('studentCount'))
</code></pre>

<p>Unfortunately that's not suitable. My ideal solution would grab whatever is between '[[' and ']]' and then run the 'get' method and replace the entire key ('[[...]]') with whatever is returned.</p>
