PHP – use a regular expression to extract a URL from XML attribute

I was working on an API response, which provided data in a custom XML markup within the string, which was returned. I wanted to simply extract the “linkTerm”. The snippet I got looked like this:

Now surely there will be more elegant ways of doing it, but I felt that I wouldn’t be guaranteed […]

Scroll to top