I'm extracting text from a database, in which are various tags.
For example:
this is a page of text, there is another [page=5]page[/page] here or you can download this [document=3]document[/document] or this [document=4]document[/document]
I need to find each tag type and replace its content with different text, so in this example whatever the folder/file is for page 5, and the same for whatever documents 3 and 4 would be.
My first thought was to look through the string, initially looking for [page= or [document=, then extract everything after that up to the ], so I'd get the database id for each docoument or page.
Then i could query the database for those document/page id's, and replace [page and [document tags with proper links and their locations.
But I think there must be a more efficient way to achieve this.
Is there a simpler way of extracting the [page and [document values into say an array?
Then I could just loop through that array, do the database querys, and replace what i need?
You probably want rematch. It will return an array of matches.