preg_replace
description
Searches $subject for matches to $pattern and replaces them with $replacement.
declaration of preg_replace
mixed preg_replace ( mixed $pattern , mixed $replacement , mixed $subject [, int $limit ] [, int &$count ] )
test preg_replace online
share preg_replace
comments for preg_replace
On 09. Jun 2017 03:26 greatfull wrote:
Thank that was very helpful. your site made it to my favorite list.
On 16. Oct 2014 12:15 zxcat wrote:
array() in $pattern doesn't work here
On 24. Jun 2014 18:58 Florian wrote:
Nice tool, good job :) One small remark though. If you try to use backreference it wont work as you'd expect, here is the code generated for these values: $pattern => /the (dog|rat|duck) is ill/ $replacement => A \${1} is running $subject => the dog is ill preg_replace('/the (dog|rat|duck) is ill/', 'A \\${1} is running', 'the dog is ill', -1, $count); It fails because the $replacement (i.e 'A \\${1} is running') is set between simple quotes and not double quotes, also because of the backslash added.
more comments for preg_replace
There are some more comments for preg_replace(). To see them all click here.