Greetings,
Iv'e made a rapid search in the previous questions but did not find an adequate answer for my question.
I have create a function that finds words in an array library and replace these by links to the description of the word.
Example :
$words = array("ANTIM","APDIV","APVEG","ARCHE","ARFEU","ARMUR",
"ARSUP","ARTHE","ARTIL","ASSOM","ATTSU","BANQU","BARDE","BRICO",
"CAMOU","CHANC","CHAOM");
When I call my function, replace_text($someString). I search for these words in the text. Although these words are in several pages of my website and all need to link to there respective description. I made that function in order to automate the process and not write the links manually.
So when I call :
replace_text("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis ultrices congue condimentum. Integer tempor aliquam ARFEU nisi at adipiscing. Vivamus ornare consequat metus. Nulla mollis lacus sit amet dolor rutrum sollicitudin. Maecenas sit amet nibh ut turpis bibendum rutrum et a tellus. Fusce a tortor a lacus feugiat gravida. Suspendisse elementum hendrerit urna ut viverra. Pellentesque ARCHE auctor, metus vitae lobortis vestibulum, justo ligula ultrices magna, vitae blandit mauris sapien eu velit. Nullam dapibus tristique orci, ac ullamcorper lectus venenatis ARTIL non. Nulla laoreet laoreet pretium.")
This will be replaced by :
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis ultrices congue condimentum. Integer tempor aliquam <a href="somelink">ARFEU</a nisi at adipiscing. Vivamus ornare consequat metus. Nulla mollis lacus sit amet dolor rutrum sollicitudin. Maecenas sit amet nibh ut turpis bibendum rutrum et a tellus. Fusce a tortor a lacus feugiat gravida. Suspendisse elementum hendrerit urna ut viverra. Pellentesque <a href="somelink">ARCHE</a auctor, metus vitae lobortis vestibulum, justo ligula ultrices magna, vitae blandit mauris sapien eu velit. Nullam dapibus tristique orci, ac ullamcorper lectus venenatis <a href="somelink">ARTIL</a> non. Nulla laoreet laoreet pretium."
(The words found from the array were replaced with anchors.)
Finally, I want my function to be called but by searching within my whole pages (html code) automatically when loaded. I think this can be done with the domDocument part of PHP but I am not used to it, can you guide me please ?