PHP Convert String to Variables (Regex)?

Adam Johnson

New member
As a result of a program I get a string back which is in the following format:

Country Name (CountryAbbr)

eg: UNITED KINGDOM (UK)

What is the best way to convert the two to variables? I'm assuming it would be something to to with regex?

But it should be something like:

$String = "UNITED KINGDOM (UK)";
function('$CountryName ($CountryAbbr)', $String);

echo $CountryName;;
echo $CountryAbbr;

Would return:

UNITED KINGDOM
UK

What would the missing function(s) be?

Thanks!
 
Back
Top