john
john

Reputation: 1280

Leaving a Space for a Variable in MySQL/PHP

I'm sure I've seen this done before but without knowing what it's called I'm struggling to find any tutorials etc.

Basically i want to store a string in MySQL but leave a space for a different variable each time.

I'm pretty sure I've seen a better way, but just to explain the problem I'm trying to get around... I want something like the following string stored in my MySQL table, that I'd then put into a PHP variable:

"This user has ##variable## points left before reaching the next
level"

Then in PHP I'd do:

str_replace("##variable##", $new_var, $mysql_string);

I know the above way would work, but I'm sure there's a better way that I've seen somewhere. Have i imagined it?

Upvotes: 0

Views: 203

Answers (1)

David
David

Reputation: 36454

sprintf(gettext("some text %s"),$variable); 

Where %s is replaced by $variable.

Upvotes: 2

Related Questions