Something like this
DB::table('your_table')->selectRaw("replace(your_column, '$username', '?')", [$username])->get();
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I get a text-string from a mySQL-request which contains some variables i want to fill.
The string i get from the mySQL-Table is like "This is something from $username" and i want to fill the "$username" with a value.
As i am very new to programming i get mad searching the web how to fill this variable with any value. If i define $username = "Joe Doe"; this does not fill the $username-Variable witthin the string.
Can someone help?
Please or to participate in this conversation.