如何使用preg_replace选择URL并将其更改为文本

I have a text like this:

Tapez ici le message que vous souhaitez envoyer à vos clients http://go.tanger.fr/m/125

I have already created a regex to select the link:

/(http(s)?:\/\/go.tanger.fr\/m\/)(\d+)/i

I want to change the link so that it looks like this:

http://go.tanger.fr/m/125?id=xxx

It looks like you just want to use the last digits as a query string.

You can achieve this with

$re = "#(https?):\/\/go\.tanger\.fr\/m\/(\d+)#i"; 
$str = "Tapez ici le message que vous souhaitez envoyer à vos clients https://go.tanger.fr/m/123"; 
$subst = "$1://go.tanger.fr/m/125?id=$2"; 
$result = preg_replace($re, $subst, $str);

Here is an IDEONE demo

Use ($string is the string in which you want to change):

preg_replace('/(http(s)?:\/\/dominos.mylittlebiz.fr\/m\/)(\d+)/i', 'http://go.tanger.fr/m/\1?ID=XXX', $string);