Re: Count and Preg_Replace Using Version 4.4.1

From: Date: Sun, 04 Dec 2005 19:00:00 +0000
Subject: Re: Count and Preg_Replace Using Version 4.4.1
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-226840@lists.php.net to get a copy of this message
"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" action="/index.php?action=edit_paragraph&file='.$_GET['file'].'" method="post"> <input type="hidden" name="old_html" value="'.htmlentities($matches[0]).'"> <p><a href="javascript:;" onclick="document.form.submit();">'.$matches[1].'</a></p> </form>'; } But I still can't see how I can increment a value in each return string?

« previous php.general (#226840) next »