Consider I have a text of 300-400 words with some basic html. Example:
<p>text text word1 text text text filament text text text text text text text text</p>
<p>text text text text text text text text text text text text text text text</p>
And I have a list of keyphrase with their urls associated (about 1000 records)
word1 word2 => 'url'
house home => 'url1'
flower filament => 'url2'
I need to place the url for the corrispondent word found in text. Example:
<p>text text <a href="url">word1</a> text [etc..]
I Know I can use a simple str_replace or preg_replace. But i dont’ want to add to many links. Out of 300-400 words i don’t want to put more than 5-6 links.
What can I Do?
use preg_replace() with the limit parameter, of course it will be the first X replacements, which may or may not be what you want