Re: Parsing brackets in text

From: Date: Tue, 14 Nov 2006 09:17:45 +0000
Subject: Re: Parsing brackets in text
References: 1 2 3 4 5 6 7 8 9 10  Groups: php.general 
Request: Send a blank email to php-general+get-244586@lists.php.net to get a copy of this message
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; ?>

« previous php.general (#244586) next »