- str_replace: documentation ( source)
- ucfirst: documentation ( source)
<?php
$pj = array('title' => 'My Title Pj', 'price' => '4 $', 'comment' => 'Cool!', 'favicon' => './img/favicon-435.jpg');
$tmp = "Title.... {Title} \r\n";
$tmp .= "Price: {Price} \r\n";
$tmp .= "Comment: {Comment} \r\n";
foreach($pj as $k => $v){
$k = ucfirst($k);
$tmp = str_replace("{$k}", $v, $tmp);
}
echo $tmp;