Last active
August 29, 2015 14:02
-
-
Save GuillaumeJasmin/9384a9b1c12b05c44c39 to your computer and use it in GitHub Desktop.
Templating php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$content = "I'm {{name}}, I live in {{location}}"; | |
$var['name'] = 'Max'; | |
$var['location'] = 'Paris'; | |
preg_match_all('|{{(.*?)}}|',$content, $matches); | |
foreach ($matches[1] as $key => $value) { | |
$content = str_replace('{{' . $value . '}}', $var[$value], $content); | |
} | |
echo $content; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment