Jump to content

Str_ireplace() Help


TEENFRONT

Recommended Posts

Hey! Heres hoping you can help :-)

 

OK..im doing like an auto linking things for my websites articles, getting certain text within the article to link back to other articles..such as this

 

if "Online Games" is find in this article text, link "Online Games" to online-games.html (which is an exisitng page)

 

Im having a little trouble with the actual linking though...

 

For example

 

the article text is "i like playing online games"

 

So the script whizzes through and replaced "online games" with the link to that article... however, i ALSO have an article called "playing online games" so on the second run, it will replaced "playing online games" with a link to that article and i end up with a double link :( like this

 

<a href="articles/Online-Games.html" title="Online <a href="Play-Online-Games.html" title="Play Online Games">Play Online Games</a>">Online <a href="http://www.8baller.co.uk/articles/1/Pool-Games.html" title="Online Games">Games</a></a>

 

the above is a little wrong in terms of what is replaced..i mocked it up... but its nasty right? lol. so its basically re-replacing the text in the link, with another link to another article..

 

So, how do i stop this? how do i tell if that part of the text has already been replaced with a link and stop replacing for that one?

 

So it needs to replace "Online Games" in the text, but if its already been replaced, dont replace "Playing Online Games" match with a link.

 

im confused and my heads gunna explode lol.

Link to comment
https://forums.phpfreaks.com/topic/134844-str_ireplace-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.