Posted By

uberdragon on 04/12/11


Tagged


Versions (?)

template


 / Published in: PHP
 

  1. // allows pulling info in from a txt file and dumping into a string.
  2. function includeIntoString($sFilename) {
  3.  
  4. if ($_SERVER['DOCUMENT_ROOT']) { $path = $_SERVER['DOCUMENT_ROOT']; }
  5. require($path.'/'.$sFilename);
  6. return ob_get_clean();
  7. }
  8.  
  9.  
  10. function getTemplate($sFilename,$array) {
  11. $html = includeIntoString('templates/folder/'.$sFilename);
  12. foreach ($array as $key => $pair) {
  13. $html = str_replace('{'.$key.'}',$pair,$html);
  14. }
  15. $html = preg_replace('/{.*?}/i','',$html);
  16.  
  17. return $html;
  18. }

Report this snippet  

You need to login to post a comment.