Using PHP and/or Codeigniter, I want to create some string templates to be store in a database so that later, they can be used to print out a customize statement.
For example, I want to store this "hello %s! you are the %d visitor."
in my database so that later I can plug in a name and number to print out this message "hello bob! you are the 100 visitor"
.
Are there any available functions to easily do this or will I have to write my own script using preg_match/preg_replace?
This works:
<?
$test = 'hello %s';
$name = 'bob';
printf( $test, $name );
?>
Read more: http://php.net/manual/en/function.printf.php