<?php
	function bbcode($data)
	{
		$input = array(
			'/\[b\](.*?)\[\/b\]/is',
			'/\[b\](.*?)$/',
		);
		$output = array(
			'<b>$1</b>',
			'<b>$1</b>',
		);
		return preg_replace ($input, $output, $data);;
    }

$bcode = bbcode('[b]this is testing text');
echo $bcode;