I’ve spent hours trying to get my code to work, its a rats nest of if/elses. Basically I want to check a country name against these two arrays:
//if its in this array add a 'THE' $keywords = array('bahamas','island','kingdom','republic','maldives','netherlands', 'isle of man','ivory','philippines','seychelles','usa'); //if its in this array, take THE off! $exceptions = array('eire','hispaniola');
and thats it.
Its sending me batty, and to be honest I’m embarassed to show you my code. Lets just say it has 2 if statements, 2 else statements and 2 foreach loops. Its a blooming mess, and I was hoping someone can dumbfound me by showing me a good way of doing this? I expect there is a way using only 1 line of code, or something sickening like that. Thank you.
This builds on @sgehrig’s answer, but note the change in your exceptions: