I have an array which associates Sports leagues with their specific Sport. I want to find the league and return the sport. I've tried using strtr but that doesn't seem to be the correct way.
$leagues = array("NHL" => "Ice hockey", "Premier League" => "Football");
$sport = strtr("NHL",$leagues);
This works and returns "Ice hockey". The problem is that the original data might contain different variations of the Sport leagues, so there might be both "NHL" and "NHL Playoffs" that I would like to both return only as "Ice hockey" without having to specify all variations in the array.
$leagues = array("NHL" => "Ice hockey", "Premier League" => "Football");
$sport = strtr("NHL Playoffs",$leagues);
So this for example, returns "Ice hockey Playoffs" when I would like to return only "Ice hockey". How can I solve this?