I have a paragraph of text in the following format:
text text text <age>23</age>. text text <hobbies>...</hobbies>
I want to be able to
1) Extract the text found between each <age>
and <hobbies>
tag found in the string. So for example, I would have an array called $ages
which will contain all ages found between all the <age></age>
tags, and then another array $hobbies
which will have the text between the <hobbies></hobbies>
tags found throughout the string.
2) Be able to replace the tags which are extracted with a marker, such as {age_444}, so e.g the above text would become
text text text {age_444}. text text {hobbies_555}
How can this be done?