I want to know how to replace some text in php string to different values using preg_replace.
For example :
- http://www.mysite.com/?uid=123456
- http://www.mysite.com/?uid=123456
- http://www.mysite.com/?uid=123456
I want this result :
- http://www.mysite.com/?uid=456789
- http://www.mysite.com/?uid=789456
- http://www.mysite.com/?uid=159753
I have used this code :
$string = 'http://www.mysite.com/?uid=123456<br/>
http://www.mysite.com/?uid=123456<br/>
http://www.mysite.com/?uid=123456';
$string = preg_replace(array("~123456~", "~123456~", "~123456~"), array("456789","789456","159753"), $string);
echo $string;
but it gives me this result :
- http://www.mysite.com/?uid=456789
- http://www.mysite.com/?uid=456789
- http://www.mysite.com/?uid=456789
Any help ?
Thanks !