|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
Automatically adding lnks to selected words in an article
Is there a way to have php scan through a document to find certain words listed in a database and then automatically attach a hyperlink to them?
Example: Article contents: Hi, this article is about Osiris. He was a great man in ancient Egypt blah blah blah I want Osiris to link to another page with a listing of all pages about Osiris. Also, Egypt will link to another page with a listing of pages about Egypt. This would also be used for images where the link would be from a word in the article to an image file. I'm guessing this would be an advanced level situation and I have no idea how it should be done so any help would be appreciated. Scurvy |
|
#2
|
|||
|
|||
|
This is pretty simple is do.
There are a number of ways you can do this. I will give you an example of how this can be done using link entries that are located in a flat text file -> Code:
Egypt|yourpage.com/egypt.html Osiris|yourpage.com/osiris.html Ok, the above would be the link_data.txt file. This file will hold all your link data, or data you want to link from your articles. The data to the left of the pipe will be the link names and the data to the right of the pipe is the actuall links. Each entry is on its own line in the file (no whitespace inbetween lines) PHP Code:
The above is your function. Call the function as so -> PHP Code:
--------------------------------------------------- There are many other ways this can be done also, this is only a simple way of doing it. If you need the words to be case insensative, then replace the str_replace() with preg_replace() or other reg exp.......
__________________
~ Joe Penn We work for free to help make this a valuable resource on the internet. Do you appreciate the help - did we provide help that will help you prosper and help that has contributed to sharpening your current skill set? Show your appreciation and purchase something from our Amazon Wishlist's - it's simple and a great way to say thank you. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > Automatically adding lnks to selected words in an article |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|