Hi there,
I would like to be able to perform a substring search for lets say 'xyz', and then replace its first occurence with 'abc1', second with 'abc2'.. and so on. Is this possible somehow?
Regards
Ammar
A question regarding search and replace
Moderator: General Moderators
preg_replace() : http://www.php.net/manual/en/function.preg-replace.php
Pattern Syntax : http://www.php.net/manual/en/reference. ... syntax.php
Pattern Syntax : http://www.php.net/manual/en/reference. ... syntax.php
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
preg_replace can only do this with a cleverly set pattern and replacement string.
preg_replace_callback() may be of a bit more use, as it does some of the trickery for you.
http://php.net/preg_replace_callback
preg_replace_callback() may be of a bit more use, as it does some of the trickery for you.
http://php.net/preg_replace_callback