How can a specific word be replaced with a link in PHP, similar to other forums?

To replace a specific word with a link in PHP, you can use the `str_replace()` function to search for the word and replace it with an anchor tag containing the link. This can be useful for creating automatic links or replacing certain keywords with relevant URLs in a forum or website.

<?php
$text = "This is a sample text where we want to replace the word 'forum' with a link.";

$word = 'forum';
$link = '<a href="https://example.com/forum">forum</a>';

$new_text = str_replace($word, $link, $text);

echo $new_text;
?>