用另一个字符串替换echo中的{text}

I am not sure what this is called, so sorry if the title is confusing.

In my database i have a table called scripts.

In this i have the column 'script' which is LongText.

I am then echoing it in a php file.

In the script (LONGTEXT) it contains the text {name}.

For example : Hello, this is {name} calling.

Lets say on the php file i have

$username = "Jack";

is there a way of replacing {name} with "Jack"? automatically.

thanks

Try this:

$newText = str_replace('{name}', $username, $data['text']);

Check this PHP: str_replace - Manual