we got an XML-Output like this one:
<phone>
<countryCode>+45</countryCode>
<areaCode>354</areaCode>
<subscriberNumber>1631616</subscriberNumber>
</phone>
How can I convert this in a string seperated with whitespaces:
+45 354 1631616
with preg_match_all
as result?
I have an application that can only use preg_match_all
(because of some other dependencies).
I tried the following:
/\<phone\>\s+\<\D+\>(\+\d+)\<\/\D+\>\s+\<\D+\>(\d+)\<\/\D+\>\s+\<\D+\>(\d+)\<\/\D+\>\s+\<\/phone\>/i
This produce 3 results:
Group 1: +45
Group 2: 354
Group 3: 1631616
because of 3 Brackets '()' (I think we speak about Backreferences?).
But I need a result of only one group
Group 1: +45 354 1631616
Seperated with Whitespaces. Is this possible with preg_match_all
(not preg_replace
) ? If not possible with whitespaces it is also OK.
Thanks for your thoughts.