Re: Parsing brackets in text

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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;

?>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux