Hello,
I am using preg_replace to change the content retrieved from a file, but I would like to incrementally mark the change of each occurence.
For instance :
have the text :
<td class="bodyText" align="center">01/04/2008</td>
<td class="bodyText" align="center">6,70</td>
<td class="bodyText" align="right">5,02</td>
<td class="bodyText" align="right">2.430</td>
<td class="bodyText" align="center">6,72</td>
<td class="bodyText" align="center">6,48</td>
<td class="bodyText" align="right">15.942,22</td>
<td class="bodyText" align="right">20</td>
<td class="bodyText" align="center">6,48</td>
in a file retrieved with fread in a variable called $sul
and use :
$sul = preg_replace('#<td class=\"(.*?)\" align=(.*?)>#',' JAZZ ', $sul);
This will return :
JAZZ 01/04/2008</td>
JAZZ 6,70</td>
JAZZ 5,02</td>
JAZZ 2.430</td>
JAZZ 6,72</td>
JAZZ 6,48</td>
JAZZ 15.942,22</td>
JAZZ 20</td>
JAZZ 6,48</td>
Now what i would like to achieve (if possible) is to have each replacement incrementally marked during the preg_replace, so as to arrive to something like :
JAZZ1 01/04/2008</td>
JAZZ2 6,70</td>
JAZZ3 5,02</td>
JAZZ4 2.430</td>
JAZZ5 6,72</td>
JAZZ6 6,48</td>
JAZZ7 15.942,22</td>
JAZZ8 20</td>
JAZZ9 6,48</td>
Is this possible ? I am not even sure I am explaining this properly I hope my question is getting through.
I tried to use something like the following to see if i could do an incremental change :
do
{
$i++;
$sul=preg_replace("/BRUS/", $i,$sul);
}
while ($i<10);
But it returns it without incrementing.
1 01/04/2008</td>
1 6,70</td>
1 5,02</td>
1 2.430</td>
1 6,72</td>
1 6,48</td>
1 15.942,22</td>
1 20</td>
1 6,48</td>
If anyone could help me out with this I would greatly appreciate it
Thanks
George