Например:
Код: Выделить всё
This is my website: test.com
Here is a link: [url=https://www.test.com/hello]Click here[/url]
Код: Выделить всё
$output = str_replace('test.com', '[url=https://www.test.com/]test.com[/url]', $input);
Код: Выделить всё
This is my website: [url=https://www.test.com/]test.com[/url]
Here is a link: [url=https://www.
Подробнее здесь: [url]https://stackoverflow.com/questions/78832040/using-php-how-do-i-replace-text-in-html-but-ignore-attributes-and-existing-tags[/url]
Мобильная версия