Home > OS >  PHP string replace with html button
PHP string replace with html button

Time:07-29

is it possible to str_replace or some form of other method which allows you to replace text within some content with a html button?

I have this tag @create@ within a paragraph that I would like to replace with <a href="link here">Create Account</a>

is this possible?

CodePudding user response:

Sure, use str_replace.

Here's a quick sample:

$variable = 'Hello, create your account: @create@';
echo str_replace("@create@", "<a href=\"link here\">Create Account</a>", $variable);

The example above will output:

Hello, create your account: <a href="link here">Create Account</a>
  • Related