dunhillblue Posted March 12, 2009 Share Posted March 12, 2009 Hi, Does anybody have a php script that they might be able to share which does the following. I would like to call this script which will replace all keywords with a URL's, I want to do this for internal linking. e.g all "Cars" words will have a hyperlink to http://www.mysamplesite.com/cars.php all "Motorbike" words will have a hyperlink to http://www.mysamplesite.com/motorbike.php etc - etc Link to comment https://forums.phpfreaks.com/topic/149073-replace-keyword-with-url/ Share on other sites More sharing options...
jackpf Posted March 12, 2009 Share Posted March 12, 2009 Regex. Something like this- $exist = array( '/cars/', '/bikes/' ); $replace = array( '<a href="http://www.example.com/cars">cars</a>', '<a href="http://www.example.com/bikes">bikes</a>', ); echo preg_replace($exist, $replace, 'cars and bikes'); Link to comment https://forums.phpfreaks.com/topic/149073-replace-keyword-with-url/#findComment-782789 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.