Re: while problems

From: Date: Mon, 18 Dec 2000 07:46:47 +0000
Subject: Re: while problems
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-30841@lists.php.net to get a copy of this message
Scott Mebberson wrote: > > ... > > $content = "<a name=\"top\"></a><span > class=\"heading\">Why E > Procurement</span><br>&nbsp;<br><a > href=\"#overview\">Overview</a> | <a > href=\"#obu\">The OBU Standard</a>"; > > It screws up. So I put in a while loop (below) to try and catch all > instances of it but it doesn't seem to be looping. > > $pat = "<a href=\"#(.+)\">(.+)</a>"; > while (ereg($pat, $content)) { > $content = ereg_replace($pat, "{link | #\\1}\\2{/link}", $content); > } > > ... > I tried this example and I think you don't need a while loop here. It's a question of regex pattern for ereg_replace(); Here is what I did: <? $pat = "<a href=\"#([^\"]+)\">([^><]+)</a>"; $content = ereg_replace($pat, "{link | #\\1}\\2{/link}", $content); ?> It will replace both of links as expected: {link | #overview}Overview{/link} | {link | #obu}The OBU Standard{/link} Hope this helps. :) -- Pavel a.k.a. Papi

« previous php.general (#30841) next »