<?php
$addr = "http://www.example.com/?pk_lol=VAgin&utm_campaign=printemps&utm_medium=e-mail&utm_source=newsletter1&utm_content=lien-en-haut";
$pattern ="@^(utm_source=)?(&)";
preg_match($pattern, $addr, $result);
echo $result[0];
// repérer le nom de l'hôte dans l'URL
preg_match('@^(?:http://)?([^/]+)@i',
"http://www.php.net/index.html", $matches);
$host = $matches[0];
echo "OOoo: {$host}\n";
// repérer les deux derniers segments du nom de l'hôte
preg_match('/[^.]+\.[^.]+$/', $host, $matches);
echo "Le nom de domaine est : {$matches[0]}\n";
?>
echo $addr;
Warning: preg_match(): No ending delimiter '@' found in /in/hn2kJ on line 7
Warning: Trying to access array offset on null in /in/hn2kJ on line 8
OOoo: http://www.php.net
Le nom de domaine est : php.net
echo $addr;
Warning: preg_match(): No ending delimiter '@' found in /in/hn2kJ on line 7
Warning: Trying to access array offset on value of type null in /in/hn2kJ on line 8
OOoo: http://www.php.net
Le nom de domaine est : php.net
echo $addr;
Output for 7.4.0 - 7.4.25, 7.4.27 - 7.4.33
Warning: preg_match(): No ending delimiter '@' found in /in/hn2kJ on line 7
Notice: Trying to access array offset on value of type null in /in/hn2kJ on line 8
OOoo: http://www.php.net
Le nom de domaine est : php.net
echo $addr;
<br />
<b>Warning</b>: preg_match() [<a href='function.preg-match'>function.preg-match</a>]: No ending delimiter '@' found in <b>/in/hn2kJ</b> on line <b>7</b><br />
OOoo: http://www.php.net
Le nom de domaine est : php.net
echo $addr;
Output for 4.3.11, 4.4.0 - 4.4.2
<br />
<b>Warning</b>: preg_match(): No ending delimiter '@' found in <b>/in/hn2kJ</b> on line <b>7</b><br />
OOoo: http://www.php.net
Le nom de domaine est : php.net
echo $addr;
Output for 4.3.0 - 4.3.10
<br />
<b>Warning</b>: No ending delimiter '@' found in <b>/in/hn2kJ</b> on line <b>7</b><br />
OOoo: http://www.php.net
Le nom de domaine est : php.net
echo $addr;