Jump to content

mwhym

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

mwhym's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Sigh ... you are right... i am being stupid Sorry for the confusion the error was due to how I was outputing the result. It does work properly... Sorry again and thanks alot for the help.
  2. Ahhh thanks so much This last bit worked like a charm (only prob was the single quotes around the function in the preg_replace) just updated it to : $sul=preg_replace_callback('#<td class=\"(.*?)\" align=(.*?)>#',UpdCounter, $sul) One things (more of a curiosity as it doesnt really matter for my purposes) why does it start the count at 10 ? Starts at JAZZ10 and then increments by one normally - but cant figure out why it starts at 10 and not 1. Thanks a million for the help everyone much appreciated. George
  3. Still with this last bit of code it only replaces the first instance with JAZZ10 and then ignores the rest. Thanks alot. George
  4. Thanks for the input much appreciated. I tried it out but it confused me a bit. As you pasted it - it replaces the first occurence only and returns it like : JAZZ10 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> -------------------------------------------------- I tried to differentiate it a bit : <?php do { $i++; $sul=preg_replace('#<td class=\"(?:.*?)\" align=(?:.*?)>#', "JAZZ".$i,$sul, 10); }while ($i<10); ?> This almost worked changed the first instance to JAZZ1 - then the next 10 to JAZZ2 - then the next 10 to JAZZ3 LIKE : JAZZ1 01/04/2008</td> JAZZ2 6,70</td> JAZZ2 5,02</td> JAZZ2 2.430</td> JAZZ2 6,72</td> JAZZ2 6,48</td> JAZZ2 15.942,22</td> JAZZ2 20</td> JAZZ2 6,48</td> JAZZ2 01/04/2008</td> JAZZ2 6,70</td> JAZZ3 5,02</td> JAZZ3 2.430</td> JAZZ3 6,72</td> JAZZ3 6,48</td> JAZZ3 15.942,22</td> JAZZ3 20</td> JAZZ3 6,48</td> Its a step forward though thanks will keep wrestling with it
  5. 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
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.