Make text between asterisks bold

A simple regex will do the trick:

$thenewtext = preg_replace('#\*{2}(.*?)\*{2}#', '<b>$1</b>', '**Hello World** of PHP');

Leave a Comment