Menu

#13 Convert urls and email addresses to real tags

open
nobody
None
5
2004-02-01
2004-02-01
No

I thought it useful for urls and email addresses to be
converted to html on the public site (i.e. a
href="...") so I edited glossary.php with (hopefully it
will show up...):

function glossary_get($key) {

global $GLOSSARY;

$output = $GLOSSARY[$key];
$output =
preg_replace("/http:\/\/([\._a-z0-9-]*[\/\._a-z0-9-]*)/i","<a
href=\"http://\\1\">\\1</a>",$output);
$output =
preg_replace("/([\._a-z0-9-]+@[\._a-z0-9-]+\.[a-z]{2,4}(\.[a-z]{2})?)/i","<a
href=\"mailto:\\1\">\\1</a>",$output);

return $output;
}

Discussion

  • Anonymous

    Anonymous - 2004-02-01

    Logged In: YES
    user_id=962839

    Okay, it cut out the &gt;a and &gt;/a&lt; that prepend and
    append the second parameter of the preg_replace statements,
    but you get the idea.

     
  • Anonymous

    Anonymous - 2004-02-01

    Logged In: YES
    user_id=962839

    I mean &lt;a and &lt;/a&gt;...

     

Log in to post a comment.

MongoDB Logo MongoDB