geekinchief Posted September 11, 2009 Share Posted September 11, 2009 I'm writing a PHP script which will take a list of product names from a database (each name is probably 1-3 words in length) and go through the text of a blog post and link any of the names on the list back to a page about that item. Additionally -- and this is key -- I need to make sure it DOES NOT turn the term into a link if it is already inside a link (inside of <a> </a> tags) The data table contains the name of the product (ex: HP Pavilion dv4t or "iPhone") and the URL for the link to it. There will be thousands of product names though very few will be used in any given blog post (maybe 1 to 4) so I don't think it's practical to do a search replace for each them on each post, but I could be wrong. I suppose I could have it compare every 3,2, and 1 word combination in each blog post to each product name. What would you suggest? Quote Link to comment https://forums.phpfreaks.com/topic/173929-automatically-linking-1-3-word-phrases-in-article-text/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.