使用php自定义文本格式

Using PHP, how would I convert an HTML string say, '+text+' to '<em>text</em>' so that if a user types +text+ in an input, it outputs as text?

You can use str_replace along side explode or regex

$text_string = '+TEST+';
$text = explode("+", $text_string);
$text = $text[1];
$replaced_text = str_replace("+$text+", "<em>$text</em>", $text_string);
echo $replaced_text; // output: <em>TEST</em>

if all you want to do is use you can do.

$input = "+text+";

$input = trim($input, '+');

$input = '<em>' . $input . '</em>';