All pastes #903717 Raw Edit

Miscellany

public php v1 · immutable
·published 2008-02-14 12:22 UTC
rendered paste body
	function parse($text) {		$text = nl2br($text);		$text = preg_replace('/\[url=(.+?)\](.+?)\[\/url\]/is', '<a href="${1}">${2}</a>', $text); // [URL=http://mysite.com]check out my site[/URL]		$text = preg_replace('/\[b\](.+?)\[\/b\]/is', '<b>${1}</b>', $text); // [b] this text is bold[/b]		$text = preg_replace('/\[u\](.+?)\[\/u\]/is', '<u>${1}</u>', $text); // [u] this text is underlined[/u]		$text = preg_replace('/\[i\](.+?)\[\/i\]/is', '<i>${1}</i>', $text); // [i] italic text[/i]		$text = preg_replace('/\[img=(.+?)\]/is', '<img src="${1}">', $text); // [img=http://www.image.url]		$text = preg_replace('/\[right\](.+?)\[\/right\]/is', '<p align="right">${1}</p>', $text); // [right] text to be aligned to the right[/right]		$text = preg_replace('/\[left\](.+?)\[\/left\]/is', '<p align="left">${1}</p>', $text); // [left] text to be aligned to the left[/elft]		$text = preg_replace('/\[center\](.+?)\[\/center\]/is', '<center>${1}</center>', $text); // [center] text to be centred on the page[/center]		$text = preg_replace('/\[color=(.+?)\](.+?)\[\/color\]/is', '<font color="${1}">${2}</font>', $text); // [color=(red|white|blue|etc)] color this text[/color]		$text = preg_replace('/\[size=([1-5])\](.+?)\[\/size\]/is', '<h${1}>${2}</h${1}>', $text); // [size=(1-5)] change the size of the text based on the <h> tag, 1 being largest, 5 being smallest[/size]		$text = preg_replace('/\[font=(.+?)\](.+?)\[\/font\]/is', '<font face="${1}">${2]</font>', $text); // [font=arial] I want this text written in arial[/font]		$text = preg_replace('/\[pic=(.+?)\]/is', '<img src="http://officialzezima.com/osi/${1}">', $text); // [pic=Quest_pic_3] On site uploaded images used with the quick access uploader		$text = preg_replace('/\[hide=(.+?)\|(.+?)\](.+?)\[\/hide\]/is', '<a href="javascript://" onClick="t_v(\'${1}\')">${2}</a><br><div id="${1}" style="z-index:1; display:none;">${3}</div>', $text); // [hide=map|Showtext][IMG=url.to.map.png][/hide] to make "Map" a quicklink to expand showing the map, but otherwise hiding the map.		$text = preg_replace('/\[item=(.+?)\]/is', '<img src="http://officialzezima.com/item/${1}">', $text); //[item=santa hat] Will pull an item of a santa hat from the item database.				return $text;	}