Jump to content

Replace all string patterns with a string variable.


flash gordon

Recommended Posts

I can't seem to get this for the life of me. Maybe a hint would help. Here is what I'm trying to do
[code]
<Parent id="7">
  <child />
  <child />
</Parent>
<Parent id="2">
  <child />
  <child />
</Parent>
<Parent id="44">
  <child />
  <child />
</Parent>
[/code]
To make it look like this:
[code]
<Parent id="0">
  <child />
  <child />
</Parent>
<Parent id="1">
  <child />
  <child />
</Parent>
<Parent id="2">
  <child />
  <child />
</Parent>
[/code]
I'm sure there is an easy way and I'm over complicating the issue. Any tips?
:)

btw, I have tried preg_replace() but I seem to replace all patterns with the same string. I need the id to increment....

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.