Actually, preg_replace() can solve Dotan Cohen's problem. There was just a
minor mistake in the code.

Please try this:

<?php

function makeLink($title) {
   $returnString="<b>$title</b>";
   return $returnString;
}

$articleText="This is a very [long] and [stupid] string.";
$articleText=preg_replace('/(\[[a-z]+\])/e', "makeLink('$1')",
$articleText);
print $articleText;

?>

Reply via email to