| Home | Geschichten | Kunst | Computer | Tindertraum |
function parsetemplate ($templatestr, $infohash) {
// replace placeholders like {foo}
// in templatestr with
// corresponding values from infohash
function lookup ($s, $h) {
if ($h{$s}) {
return $h{$s};
} else {
return "<!-- unknown: $s -->";
}
}
$result = preg_replace (
"/{(w+)}/e",
"lookup('$1', $infohash)",
$templatestr
);
return $result;
}
[ by Martin>] [permalink] [similar entries]
similar entries (vs):
similar entries (cg):