PHP - preg_replace

Hi Forums,

Ok, so I have a string made up of html like so:


<div style="blahblah">%1</div><div>%2</div>

And I am using php to strip the tags, explode the string in order to leave just %1 and %2. Now I am using preg_replace to reconstruct the data before the tags were stripped but replace the %1 and %2 with html data pulled from a database. This all works fine.

The problem I have is that when the %n (where n is a number) exceeds single digits, the regular expression I am using will only look at the first digit. Here is my regex:

"/%['. $this_item .']/"

Where $this_item can be any number from 0-infinity (or in this case, 100000 :wink: ) and corresponds to an ID number from a database.

Any help would be appreciated, perhaps using a different technique would suffice?

Cheers!