Jump to content

Recommended Posts

This has been getting to be for quite some time now. anyway this is what i have:

 

'<span style="font-size: 11px;">Code:</span><br />
<div style="border: 1px black solid; background: #CCC; width: 99%; max-height: 24em; display: block; white-space: nowrap; overflow: auto;
line-height: 1.3em; overflow: auto;">'.highlight_string(stripslashes('$1'), TRUE).'</div>',

&

'~\[code\](.*?)\[\/code\]~is',

 

How ever, it just does not format it to highlight it.

 

This is the output:

 

Code:

<?php

echo 'Please work?';

?>

 

and from the <?php it just prints black.

 

This is what i use to also get it to highlight..

 

<?php
echo 'Please work?';
?>

 

and it seems like it just does not want to work.

 

Can anyone help with this?

Link to comment
https://forums.phpfreaks.com/topic/153729-help-with-highlight_string/
Share on other sites

Would be so much easier if you showed us the complete script. I'm guessing you're looking for something like this:

 

<?php
echo preg_replace('~\[code\](.*?)\[/code\]~ise', "'<span style=\"font-size: 11px;\">Code:</span><br />
<div style=\"border: 1px black solid; background: #CCC; width: 99%; max-height: 24em; display: block; white-space: nowrap; overflow: auto;
line-height: 1.3em; overflow: auto;\">'.highlight_string(stripslashes('$1'), TRUE).'</div>'", $str);
?>

thebadbad's code does what you asked.  It highlights the stuff between the code tags, wrapped in the styling you want.  If you had bothered to try it out, you would have seen that it does work.

 

the main thing to note is that he added the e modifier to the pattern so that the replacement will actually evaluate and execute the syntax highlighting.

Alright. The moral of the story here is that when you come to a forum to ask a question, don't be so hasty to disregard solutions given, as you clearly aren't in the know, yourself (otherwise you wouldn't be asking the question in the first place).  And it's definitely not a good idea to be an ass about disregarding it, because karma is a bitch.

 

I'm closing this thread before it gets ugly.

 

 

Guest
This topic is now 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.