Michdd Posted June 27, 2009 Share Posted June 27, 2009 I have a variable that contains HTML content, I'm trying to find and replace stuff within <highlight></highlight> tags with the text returned from the highlight_string function. It works pretty well, but for some reason the text is being moved to the topic of the html. I thought it might be an html issue, but looking at the source it is at the top. Here's my source: $html = preg_replace_callback('/<highlight>(.*?)<\/highlight>/s', create_function ( '$matches', 'return highlight_string("<?php" . $matches[1]);'), $html); Any ideas? Link to comment https://forums.phpfreaks.com/topic/163851-solved-text-position-being-changed/ Share on other sites More sharing options...
PugJr Posted June 27, 2009 Share Posted June 27, 2009 I don't see any source? Link to comment https://forums.phpfreaks.com/topic/163851-solved-text-position-being-changed/#findComment-864527 Share on other sites More sharing options...
Michdd Posted June 27, 2009 Author Share Posted June 27, 2009 That's really it, that one line. The only other thing would be the html. Which is just some html which contains <highlight>some code here</highlight> at the bottom of it all. But after it's output the highlighted text is moved to the top.. Link to comment https://forums.phpfreaks.com/topic/163851-solved-text-position-being-changed/#findComment-864528 Share on other sites More sharing options...
Michdd Posted June 27, 2009 Author Share Posted June 27, 2009 Oh, I probably should've mentioned this: The output of the function ("1") is being displayed in place where the tags are.. I couldn't figure out a way to make the output not display.. Link to comment https://forums.phpfreaks.com/topic/163851-solved-text-position-being-changed/#findComment-864534 Share on other sites More sharing options...
Michdd Posted June 27, 2009 Author Share Posted June 27, 2009 I think the problem might be relating to the fact that highlight_string outputs already, and since I'm preforming that on part of the string, then echoing the whole string over it's causing some conflict. Any ideas on how I can fix, or even just test my theory? Edit: Solution was really simple. Just needed to add the option parameter in the function, and set it to true. Link to comment https://forums.phpfreaks.com/topic/163851-solved-text-position-being-changed/#findComment-864550 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.