Convert comma separated string to array and test for entries
$PermittedCountryCodes = "FR,GB";
$PermittedCountryCodes = trim($PermittedCountryCodes);
$PermittedCountryCodes = strtoupper($PermittedCountryCodes);
$PermittedCountryCodes = explode(',', $PermittedCountryCodes); //Convert to array
$PermittedCountryCodes = array_map('trim', $PermittedCountryCodes); //Trim each array entry
if (array_search("GB", $PermittedCountryCodes) !== False)
{
//'GB' IS PRESENT
}
Convert array into comma separated string
$Types = array();
if (something)
$types[] = "SMS";
if (somethingelse)
$Types[] = "TEL";
$Types = implode(',', $Types); //Convert array to comma seperated string
Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.