lulz.php

  1. <?php
  2. public static function format($template, $data = array()) {
  3. // Initialise our replacement string.
  4. $result = $template;
  5.  
  6. foreach ($data as $key => $value) {
  7. // Work out the key that we want to replace.
  8. $key = '%{'.$key.'}';
  9.  
  10. // Make it so!
  11. $result = str_replace($key, $value, $result);
  12. };
  13.  
  14. // Here you are, sir.
  15. return $result;
  16. }
  17.