php preg_replace重用主题

I've got a big problem and hopefully you can help me out...

I'd like to code a plugin. The plugin should search on a website (for example www.example.com/index.php for a specific word for example Number1. Afterwords the word found should be replaced by an hyperlink. The link should guide to an extern website for example www.example2.com/index.php.

According to the current website, the found word should added to the hyperlink. So if the current site is www.example.com/index.php and the found word is Number1, the hyperlink should look like this:

www.example2.com/index.php/Number1

And it shouldn't be always the same hyperlink, but created dynamic by the word this plugin finds.

Beneath is my current code. I hope someone can help me out. Thanks.

public function onContentPrepare($context, &$row, &$params, $page = 0)
{
    $text = $row->text;    

    $pattern = array();
    $pattern[0] = '/Number1/';
    $pattern[1] = '/Number2/';
    $pattern[2] = '/Number3/';

    $Subject = array();
    $Subject[2] = 'https://www.example.com/index.php/';
    $Subject[1] = '(...)';
    $Subject[0] = '(...)';

    $row->text = preg_replace($pattern,$subject,$text);
}