kalster Posted December 14, 2015 Share Posted December 14, 2015 i need to change the color of a word in a string where the word is unknown (from $_POST) and may have one or more uppercase chars. code please. Quote Link to comment https://forums.phpfreaks.com/topic/299732-change-the-color-of-a-word-in-a-string/ Share on other sites More sharing options...
requinix Posted December 14, 2015 Share Posted December 14, 2015 I'm not sure I understand what you're saying. Are you telling us to give you the code to do this? Quote Link to comment https://forums.phpfreaks.com/topic/299732-change-the-color-of-a-word-in-a-string/#findComment-1527896 Share on other sites More sharing options...
kalster Posted December 14, 2015 Author Share Posted December 14, 2015 Yes, I am asking for help. code, url, ect. Quote Link to comment https://forums.phpfreaks.com/topic/299732-change-the-color-of-a-word-in-a-string/#findComment-1527897 Share on other sites More sharing options...
ginerjm Posted December 14, 2015 Share Posted December 14, 2015 Not a php question most likely. Sounds like an html one. If I were trying to highlight a part of a string being output I would wrap that part in a span tag and set a style for it. Quote Link to comment https://forums.phpfreaks.com/topic/299732-change-the-color-of-a-word-in-a-string/#findComment-1527918 Share on other sites More sharing options...
mikesta707 Posted December 14, 2015 Share Posted December 14, 2015 Also, this isn't a free code forum. its a php help forum. If you need help with some code you are writing, then this place is perfect for you. However, if you want someone to give you code, there are plenty of forums for hiring freelance developers out there. I think there is even a subforum for that here. Quote Link to comment https://forums.phpfreaks.com/topic/299732-change-the-color-of-a-word-in-a-string/#findComment-1527926 Share on other sites More sharing options...
Solution cyberRobot Posted December 14, 2015 Solution Share Posted December 14, 2015 i need to change the color of a word in a string where the word is unknown (from $_POST) and may have one or more uppercase chars. code please. Are you looking to create a keyword highlighter like you find in search engines? If so, you could look into using something like str_ireplace(). More information can be found here: http://php.net/manual/en/function.str-ireplace.php Note that there's an example keyword highlighter in the user-contributed notes here http://php.net/manual/en/function.str-ireplace.php#87417 Quote Link to comment https://forums.phpfreaks.com/topic/299732-change-the-color-of-a-word-in-a-string/#findComment-1527930 Share on other sites More sharing options...
kalster Posted December 14, 2015 Author Share Posted December 14, 2015 ty cyberRobot, that function example worked perfect. Quote Link to comment https://forums.phpfreaks.com/topic/299732-change-the-color-of-a-word-in-a-string/#findComment-1527936 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.