Welcome to the Cookbook

loading...

8.3.3 insert

string insert ($string, $data, $options = array())

The insert method is used to create string templates and to allow for key/value replacements.

String::insert('My name is :name and I am :age years old.', array('name' => 'Bob', 'age' => '65'));
// generates: "My name is Bob and I am 65 years old."
  1. String::insert('My name is :name and I am :age years old.', array('name' => 'Bob', 'age' => '65'));
  2. // generates: "My name is Bob and I am 65 years old."