|
Posted by Curt Zirzow on 12/04/05 21:31
On Sun, Dec 04, 2005 at 07:00:00PM -0000, Shaun wrote:
>
> "comex" <comexk@gmail.com> wrote in message
> news:6bf32280512040808s16253e33r6cf972cec52c5a58@mail.gmail.com...
> > form'.$count.'...
> You can use preg_replace_callback or the e pattern modifier to let you
> run php code for the replacement:
> http://us3.php.net/manual/en/function.preg-replace-callback.php
> http://us3.php.net/manual/en/reference.pcre.pattern.modifiers.php
>
> Hi Comex,
>
> Thanks for your reply, I have modified the code so I have a call back
> function:
>
> echo = preg_replace_callback( '/<p[^>]*>(.*?)<\/p>/ms', "callback",
> file_get_contents($_GET['file']) );
>
> function callback($matches){
> return
> '<form name="form" target="_parent"
> ...
>
> But I still can't see how I can increment a value in each return string?
function callback($matches) {
static $i = 0; // <-- maintains counter within function scope
$i++;
return "<form name="form$i">....</form>";
}
btw, i've been meaning to mention this in the last few posts of
yours, but have you considered using DOM to make this happen. When
ever I see a regex solution for parsing an html document, it makes
me cringe.
Curt.
--
cat .signature: No such file or directory
Navigation:
[Reply to this message]
|