Created
August 14, 2017 01:01
-
-
Save elton182/3893c0991ea6974b2aa8678371fd50d1 to your computer and use it in GitHub Desktop.
logica que faz o parse de valores {{name}}
This file contains 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
<?php | |
function resolveTemplate($template,$data){ | |
// search pattern | |
$pattern = '/{{([^}]+)}}/'; | |
$callback = function ($match) use($data){ | |
//var_dump($matches); | |
$string = trim($match[1]); | |
if(isset($data[$string])){ | |
return $data[$string]; | |
} | |
}; | |
return preg_replace_callback($pattern, $callback, $template); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment