If you can change the ##text## to say /#text#/ it would be easier as you could then do something like:
$id = substr($orig_text,strpos($orig_text, '/#')+2,strpos($orig_text, '#/')-1); $new_text = str_replace( '/#', 'href="somewhere.php?id='.$id.'">', $orig_text); $new_text = str_replace( '#/', '</a>', $new_text); see: http://www.php.net/manual/en/ref.strings.php HTH Graham -----Original Message----- From: Gareth Williams [mailto:[EMAIL PROTECTED] Sent: 30 September 2004 09:38 To: mario Cc: [EMAIL PROTECTED] Subject: Re: [PHP] Replace or regex? Well, if you can do it without a regex, then it's always best, because the regex engine slows things down. On 30 Sep 2004, at 10:39, mario wrote: > Hi all > > I have a string: ##CODE## and I want to replace that with <a > href="somewhere.php?id=CODE">CODE</a> > > can u help? > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php