Count and Preg_Replace Using Version 4.4.1

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

The following code matches all occurences of <p> tags within an html page 
and wraps form tags around it:

echo preg_replace(
    '/<p[^>]*>(.*?)<\/p>/ms',
    '<form name="form" target="_parent" 
action="'.$CFG->edit_pages_adm.'/index.php?action=edit_paragraph" 
method="post">
      <input type="hidden" name="text" value="$1">
      <p><a href="javascript:;" onclick="document.form.submit();">$1</a></p>
     </form>',
    file_get_contents($CFG->frontenddir_editable.'/'.$file) );

Unfortunately if there is more than one match the form won't submit because 
the forms have the same name. Does anyone know how can I modify this so that 
each occurence is numbered sequentially i.e.

form'.$count.'...

As I am using version 4.4.1 I don't have access to the count paramter in 
version 5.1.

Thanks for your advice 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux