Advertisement
Guest User

Markdown Light Edition

a guest
May 27th, 2011
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.69 KB | None | 0 0
  1. <?php
  2.  
  3. /*
  4.  *   This code:
  5.  *   - makes bold each part of text surrounded by ** (double star)
  6.  *   - makes italic each part of text surrounded by // (double slash)
  7.  *   - makes underline each part of text surrounded by __ (double underscore)
  8.  */
  9.  
  10.  
  11. $formatted = preg_replace( array( '#\*\*(.*)\*\*#sU',
  12.                                   '#//(.*)//#sU',
  13.                                   '#__(.*)__#sU'),
  14.                            array( '<span style="font-weight:bold">$1</span>',
  15.                                   '<span style="font-style:italic">$1</span>',
  16.                                   '<span style="text-decoration:underline">$1</span>'),
  17.                            $txt);
  18.  
  19. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement