PHP Templating Preg_Replace
===

I'm making a simple templating system in php.

If I have a variable called $var, I want [var] to be replaced with the value of $var. But I want it to work with anything in square brackets. Could anyone give me a Preg_Replace for this?