我有一个字符串,其中包含 HTML 中的 URL。我想为每个 URL 添加参数。
$my_string = "See our full range of <a href="http://www.mysite.com/cat.php?cPath=8" target="_blank">some category</a> online and also our popular <a href="http://www.mysite.com/product.php?products_id=22" target="_blank">some product</a>.";
最终应该是:
$my_new_string = "See our full range of <a href="http://www.mysite.com/cat.php?cPath=8&new_param=test" target="_blank">some category</a> online and also our popular <a href="http://www.mysite.com/product.php?products_id=22&new_param=test" target="_blank">some product</a>.";