Xriuk
Xriuk

Reputation: 392

preg_replace dynamic replacement don't work as expected

I have some problems with the fottowing code:

echo preg_replace('/^([@\.]*)$/i', '<span>$1</span>', "[email protected]");

I want to get example<span>@</span>mail<span>.</span>com", but with $1 I'm not getting the value I need... any help?

Upvotes: 0

Views: 24

Answers (1)

CMPS
CMPS

Reputation: 7769

Try this, it works

echo preg_replace('/([@\.])/i', '<span>$1</span>', "[email protected]");

Upvotes: 3

Related Questions