Advertisement
Guest User

Pre Tags

a guest
Dec 20th, 2011
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.62 KB | None | 0 0
  1. /**
  2.  * Parses [code] [/code] in a post, private message or signature.
  3.  *
  4.  * @since version 2.0
  5.  * @param string $text The text to parse.
  6.  * @return string Returns the parsed string.
  7.  */
  8. function parse_code($text)
  9. {
  10.     $ubb = array('[code]', '[/code]');
  11.     $html = array('<pre>', '</pre>');
  12.    
  13.     $text = str_ireplace($ubb, $html, $text);
  14.    
  15.     preg_match_all('`\<pre\>(.+?)\<\/pre\>`', $text, $matches);
  16.     foreach($matches[0] as $x => $value)
  17.     {
  18.         $temp = str_replace("<br />", "", $value);
  19.         $temp = str_replace("\t", "&nbsp;&nbsp;&nbsp;&nbsp;", $temp);
  20.         $text = str_replace($value, $temp, $text);
  21.     }
  22.    
  23.     return $text;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement