I have this script (which is longer) to associate a image to a news title, this works but has no order or preferance as such.
if (preg_match("/TeamName/i", "$title")) {
$img = "tt.jpg";
} else if (preg_match("/PlayerName/i", "$title")) {
$img = "jj.jpg";
} else if (preg_match("/AnotherWord/i", "$title")) {
$img = "gg.jpg";
} else if (preg_match("/AnotherTeamName/i", "$title")) {
$img = "hh..jpg";
} else if (preg_match("/GroundName/i", "$title")) {
$img = "tans.jpg";
} else if (preg_match("/uk/i", "$title")) {
$img = "uk.jpg";
} else {
$img = "image1.jpg";
}
What I mean is that if the title was "TeamName wins at GroundName" or "TeamName beats AnotherTeamName" then you are always going to show the name of the secord requirement.
How else could I do this to show a better variety of images, a lot of my articles include "TeamName" so i see the tt.jpg image a lot.