bbcode highilight

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    bbcode highilight

    hello,
    I'm trying to do a bbcode that highlight the string between [code] so i foum this.
    $string = preg_replace("/\[code\](.+?)\[\/code\]/eiU", "highlight_string(\"$1\", true);", $string);
    It works if $string in only in one line
    $string ="[ code] <?php echo 'do'; [/code ]";
    But if i make in more lines.
    $string ="[ code]
    <?php
    echo 'do';
    [/code ]";
    Not working
    Any help ?

    #2
    Try:
    PHP Code:
    $string preg_replace("/\[code\](.*)\[\/code\]/is"highlight_string($1), $string); 
    Last edited by something else; 01.12.10, 18:49.

    Comment


      #3
      code doesnt working @ s else bro

      Comment


        #4
        yes i forgot to reply, try this @ shakil
        PHP Code:
        $string preg_replace("/\[code\](.*) \[\/code\]/es","highlight_string('$1')"$string); 

        Comment


          #5
          this will work
          PHP Code:
          $string preg_replace("/\[code\](.*)\[\/code\]/isUe""'<code>\\1</code>'"$string); 
          It's better to keep your mouth shut and give the impression that you're stupid, than to open it and remove all doubt.
          ⓣⓗⓔ ⓠⓤⓘⓔⓣⓔⓡ ⓨⓞⓤ ⓑⓔ©ⓞⓜⓔ, ⓣⓗⓔ ⓜⓞⓡⓔ ⓨⓞⓤ ⓐⓡⓔ ⓐⓑⓛⓔ ⓣⓞ ⓗⓔⓐⓡ !
          ιη тнєσяу, тнє ρяα¢тι¢є ιѕ α яєѕυℓт σƒ тнє тнєσяу, вυт ιη ρяα¢тι¢є ιѕ тнє σρρσѕιтє.
          キノgんイノ刀g 4 ア乇ムc乇 ノ丂 レノズ乇 キucズノ刀g 4 √ノ尺gノ刀ノイリ!

          Comment


            #6
            witch 1 will work at uloki

            Comment


              #7
              Yeah its working, but when i post two codes at the same time like:

              first code here [ code] blah.. blah..[ /code]
              second code here [ code] blah.. blah..[ /code]

              only the first code is highlighten..
              Last edited by Wapito; 08.08.11, 17:18.

              Comment


                #8
                Try to add "m" multiline modifier to regex.
                <!DOCTYPE html PUBLIC "-//WAPFORUM.RS

                Comment


                  #9
                  I found the answer here http://coding-talk.com/f16/php-bbcode-9744/#post72413

                  Comment

                  Working...
                  X