3v4l.org

run code in 300+ PHP versions simultaneously
<?php $url = '<div><a class="nk" href="http://weibo.cn/u/1610526293?st=968f">阳光下的雪海</a><span class="ctt">:<a href="http://weibo.cn/pages/100808topic?extparam=%E4%B8%AD%E5%9B%BD%E4%B9%8B%E5%A3%B0&amp;from=feed&amp;st=968f" class="k">#中国之声#</a> <a href="http://weibo.cn/sinaurl?f=w&amp;u=http%3A%2F%2Ft.cn%2FzO2NEZA&amp;st=968f">http://t.cn/zO2NEZA</a></span> &nbsp;<a href="http://weibo.cn/attitude/zAueIaySO/add?uid=1704540003&amp;rl=0&amp;st=968f">赞[0]</a>&nbsp;<a href="http://weibo.cn/repost/zAueIaySO?uid=1610526293&amp;rl=0&amp;st=968f">转发[0]</a>&nbsp;<a href="http://weibo.cn/comment/zAueIaySO?uid=1610526293&amp;rl=0&amp;st=968f#cmtfrm" class="cc">评论[0]</a>&nbsp;<a href="http://weibo.cn/fav/addFav/zAueIaySO?rl=0&amp;st=968f">收藏</a><!---->&nbsp;<span class="ct">1分钟前&nbsp;来自手机微博触屏版</span></div>'; preg_match_all("/(?<=href=\")[^\"]+(?=\")/", $url, $match); var_dump($match); echo preg_replace("/(?<=href=\")([^\"]+)(?=\")/", "\\1&afr=ad", $url);
Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.12 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
array(1) { [0]=> array(7) { [0]=> string(36) "http://weibo.cn/u/1610526293?st=968f" [1]=> string(105) "http://weibo.cn/pages/100808topic?extparam=%E4%B8%AD%E5%9B%BD%E4%B9%8B%E5%A3%B0&amp;from=feed&amp;st=968f" [2]=> string(73) "http://weibo.cn/sinaurl?f=w&amp;u=http%3A%2F%2Ft.cn%2FzO2NEZA&amp;st=968f" [3]=> string(74) "http://weibo.cn/attitude/zAueIaySO/add?uid=1704540003&amp;rl=0&amp;st=968f" [4]=> string(68) "http://weibo.cn/repost/zAueIaySO?uid=1610526293&amp;rl=0&amp;st=968f" [5]=> string(76) "http://weibo.cn/comment/zAueIaySO?uid=1610526293&amp;rl=0&amp;st=968f#cmtfrm" [6]=> string(53) "http://weibo.cn/fav/addFav/zAueIaySO?rl=0&amp;st=968f" } } <div><a class="nk" href="http://weibo.cn/u/1610526293?st=968f&afr=ad">阳光下的雪海</a><span class="ctt">:<a href="http://weibo.cn/pages/100808topic?extparam=%E4%B8%AD%E5%9B%BD%E4%B9%8B%E5%A3%B0&amp;from=feed&amp;st=968f&afr=ad" class="k">#中国之声#</a> <a href="http://weibo.cn/sinaurl?f=w&amp;u=http%3A%2F%2Ft.cn%2FzO2NEZA&amp;st=968f&afr=ad">http://t.cn/zO2NEZA</a></span> &nbsp;<a href="http://weibo.cn/attitude/zAueIaySO/add?uid=1704540003&amp;rl=0&amp;st=968f&afr=ad">赞[0]</a>&nbsp;<a href="http://weibo.cn/repost/zAueIaySO?uid=1610526293&amp;rl=0&amp;st=968f&afr=ad">转发[0]</a>&nbsp;<a href="http://weibo.cn/comment/zAueIaySO?uid=1610526293&amp;rl=0&amp;st=968f#cmtfrm&afr=ad" class="cc">评论[0]</a>&nbsp;<a href="http://weibo.cn/fav/addFav/zAueIaySO?rl=0&amp;st=968f&afr=ad">收藏</a><!---->&nbsp;<span class="ct">1分钟前&nbsp;来自手机微博触屏版</span></div>

preferences:
253.09 ms | 409 KiB | 352 Q