Jump to content

[SOLVED] Text position being changed.


Michdd

Recommended Posts

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

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.

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.