<?php $content = '<a href="https://example.net">Awesome Button</a> <a href="https://example.net?tag=zero">Awesome Button</a> '; $params = 'param1=blue¶m2=red'; echo preg_replace_callback("/(?<=href=[\"'])([^\"'?]+)(?:\?([^\"'?]+))?(?=[\"'])/", function($x) use ($params) { return !empty($x[2]) ? $x[1] . '?' . $params . '&' . $x[2] : $x[1] . '?' . $params; }, $content);
You have javascript disabled. You will not be able to edit any code.