ki Posted December 29, 2006 Share Posted December 29, 2006 Im sorry im really off today, but whats the code (i think theres one) where it highlights a certain text in the page. Its used for search results. Link to comment https://forums.phpfreaks.com/topic/32140-idk/ Share on other sites More sharing options...
corbin Posted December 29, 2006 Share Posted December 29, 2006 Umm it could probably be done with JS a bit better, since it would look at the entire parsed page, but you could use[code=php:0]<style type="test/css">.highlight {background-color: yellow;}</style><?$rep = $_GET['highlight'];//lets pretend some how the entire contents of the page are $contentsstr_replace($rep, "<font class='hightlight'>{$rep}</font>", $contents);?>[/code]That script assumed that the entire contents of the page is in $contents, and it would create problems if a user chose to high light something like < cause then it would make it <font class='highlight'><</font> which wouldnt be a problem unless it changed something like <img src="image.jpg"> into <font class='highlight'><</font> src=...You could probably use regexps to make sure it wasnt in an html tag... Anyways, someone will probably post with a better answer than mine, but I tried :p. Link to comment https://forums.phpfreaks.com/topic/32140-idk/#findComment-149151 Share on other sites More sharing options...
ki Posted December 29, 2006 Author Share Posted December 29, 2006 ?I took that into consideration before, but i realized before i post that I thought there was another method. Link to comment https://forums.phpfreaks.com/topic/32140-idk/#findComment-149154 Share on other sites More sharing options...
bljepp69 Posted December 29, 2006 Share Posted December 29, 2006 You have to use some kind of function to accomplish this. Check out this post - [url=http://www.phpfreaks.com/forums/index.php/topic,119892.msg491766.html#msg491766]http://www.phpfreaks.com/forums/index.php/topic,119892.msg491766.html#msg491766[/url] Link to comment https://forums.phpfreaks.com/topic/32140-idk/#findComment-149156 Share on other sites More sharing options...
corbin Posted December 29, 2006 Share Posted December 29, 2006 Ummm thats basically the same as mine except in a function :p.Also, your script would have the same problem as mine... Link to comment https://forums.phpfreaks.com/topic/32140-idk/#findComment-149157 Share on other sites More sharing options...
trq Posted December 29, 2006 Share Posted December 29, 2006 Is [url=http://php.net/highlightstring]highlightstring[/url] what your after? Link to comment https://forums.phpfreaks.com/topic/32140-idk/#findComment-149159 Share on other sites More sharing options...
ki Posted December 29, 2006 Author Share Posted December 29, 2006 [quote author=bljepp69 link=topic=120230.msg492976#msg492976 date=1167360460]You have to use some kind of function to accomplish this. Check out this post - [url=http://www.phpfreaks.com/forums/index.php/topic,119892.msg491766.html#msg491766]http://www.phpfreaks.com/forums/index.php/topic,119892.msg491766.html#msg491766[/url][/quote]that worked, but i modified it so it replaces the < > and checks to see it theres still any thing to high light, and thorpe, thats what I was thinking of at first Link to comment https://forums.phpfreaks.com/topic/32140-idk/#findComment-149165 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.