news script that highlights PHP code

Discussion in 'PHP' started by a_coder_2, Nov 9, 2005.

Thread Status:
Not open for further replies.
  1. #1
    Hi!
    Does anybody of you guys now where i can find a news script that is highlighting PHP? I shall use it for articles and therefor it's importent that it highlights PHP.
    ex: if I write an article about the mail() funcsion i want it to highlight the code that i tell it to do.
    exempel by simply adding
    "{PHP} {/PHP}"

    something like this:

    "{PHP}
    mail(test@test.com, subject, mailtext);
    {/PHP}"

    and it shows the code highlighted:
    like this:
    mail(test@test.com, subject, mailtext);
    PHP:

    can anyone help me with this??
    / best regard Kip
     
    a_coder_2, Nov 9, 2005 IP
  2. dave487

    dave487 Peon

    Messages:
    701
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Assuming your article is stored as the variable $articletext then you can use the following.
    $articletext = str_replace("{PHP}", "<div style=phpcode>", $articletext);
    $articletext = str_replace("{/PHP}", "</div>", $articletext);

    This will wrap some div tags round the php code and you can then define how it will look using css.

    Not sure whether this is the best way to do it but I reckon it will work fine.
     
    dave487, Nov 9, 2005 IP
Thread Status:
Not open for further replies.