<? $link = '<a href="http://site.net/page.php?rand=91057">'; var_dump(preg_replace('/\?rand=(\d)+/', '', $link));