December 2011
2 posts
One guy thought he was invisible, the other thought he could fly. Both were...
4 tags
Replacing Placeholders in PHP
Ran across a neat little function in PHP for replacing multiple placeholder instances within a string. Here’s an example:
$string = "<strong>##title##</strong><p>##some_text##</p>";
Here’s the PHP:
echo strtr($string,
array(
'##title##' => "The Spice...",
'##some_text##' => "Will flow!!!"
)
);
Here’s the result: The Spice…...