时间:2021-07-01 10:21:17 帮助过:45人阅读
function addRandNumber($matches) { global $ar; $n = rand(1, 111); while(in_array($n, $ar)) $n = rand(1, 111); $ar[] = $n; return $matches[1].$n; } $body = "url_com
url_com
url_com"; $ar = array(); $body = preg_replace_callback( "|(com)+?|", 'addRandNumber', $body);
------解决方案--------------------
jquery实现吧。很简单的。
$("A").each(function(index, obj)
{
$(obj).attr("href", $(obj).attr("href")+"?rand="+Math,random);
})
------解决方案--------------------