<?php
$strTemplate = "My name is :name, not :name2.";
$strParams = [
':name' => 'Dave',
'Dave' => ':name2 or :password',
':name2' => 'Steve',
':pass' => '7hf2348', ];
echo "
" . strtr($strTemplate, $strParams) . "
";
echo "
" . str_replace(array_keys($strParams), array_values($strParams), $strTemplate) . "
";
?>
Output:
My name is Dave, not Steve.
My name is Steve or 7hf2348word, not Steve or 7hf2348word2.