Skip to content

Instantly share code, notes, and snippets.

@ViliamKopecky
Created September 16, 2016 15:11
Show Gist options
  • Save ViliamKopecky/2e10c82d2a0c4e9a1b3c7baffeaa540f to your computer and use it in GitHub Desktop.
Save ViliamKopecky/2e10c82d2a0c4e9a1b3c7baffeaa540f to your computer and use it in GitHub Desktop.
<?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