I have this piece of PHP to find a campaign name in string and then use substr on the occurrence of the campaign name.
$chars = array("æ", "ø", "å");
$replace = array("ae", "oe", "aa");
$dash = strpos(utf8_decode($campaign["campaign_name"]), "Studiepakke");
$decoded_name = utf8_decode($campaign["campaign_name"]);
$id_name = str_replace($chars, $replace, trim(strtolower(substr($decoded_name, 0, ($dash-2)))));
$lpage_pos = strripos($id_name, $_GET["lpage"]);
$short_name = strtolower(utf8_decode($campaign["adset_name"]));
$dash_pos = strpos($short_name, " - ");
$campaign["campaign_name"] can look like "aalborg - studiepakke", but it can also be "studiepakke - aalborg"
How can I use substr and strpos so it is unimportant whether "Studiepakke" is at the beginning or at the end of the string. My end result will always be
"aalborg".