Created
September 16, 2016 15:11
-
-
Save ViliamKopecky/2e10c82d2a0c4e9a1b3c7baffeaa540f to your computer and use it in GitHub Desktop.
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 templateString($subject, array $replace, $l = '%', $r = NULL) { | |
if(!$r) { | |
$r = $l; | |
} | |
return str_replace(array_map(function($s) use ($l, $r) { return "$l$s$r"; }, array_keys($replace)), array_values($replace), $subject); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment