I have to write a PHP function that will take a string and a substring. The string is an xml like structure and i have to return the text that goes inside the xml element say <x> blah! </x>.
for example- if the string is <x>Hey!</x> <y>test </y> <z> Yup! </z> and the substring is x, then the function should return Hey!
Second thing is there could be multiple occurance of the same element. For example- <x>Hey!</x> <y>test </y> <z> Yup! </z> <x> second time! </x>, in that case the output should be the last text within the substring element i.e. second time! in the above example.
Any input will be highly appreciated.