hyperlink - php preg_replace reuse of subject -
i've got big problem , can me out...
i'd code plugin. plugin should search on website (for example www.example.com/index.php
specific word example number1
. afterwords word found should replaced hyperlink. link should guide extern website example www.example2.com/index.php
.
according current website, found word should added hyperlink. if current site www.example.com/index.php
, found word number1
, hyperlink should this:
www.example2.com/index.php/number1
and shouldn't same hyperlink, created dynamic word plugin finds.
beneath current code. hope can 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); }
Comments
Post a Comment