TEENFRONT Posted November 30, 2008 Share Posted November 30, 2008 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 More sharing options...
The Little Guy Posted November 30, 2008 Share Posted November 30, 2008 What do you want to end up with? The first match or the second one? Link to comment https://forums.phpfreaks.com/topic/134844-str_ireplace-help/#findComment-702150 Share on other sites More sharing options...
TEENFRONT Posted November 30, 2008 Author Share Posted November 30, 2008 just the first match is fine. Many thanks Link to comment https://forums.phpfreaks.com/topic/134844-str_ireplace-help/#findComment-702151 Share on other sites More sharing options...
TEENFRONT Posted December 2, 2008 Author Share Posted December 2, 2008 Hey Never managed to solve this, so still looking for some advice on this. Link to comment https://forums.phpfreaks.com/topic/134844-str_ireplace-help/#findComment-704067 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.