Thanks a lot you guys, I really appreciate the help (great tip ahundiak)! It's still not working though, so I'll be a bit more specific with exactly what I'm trying to do:
Text file(which will actually contain quite a large number of phrases):
shopping in new york
dvd rentals
live rock music in la
cd shops
harry potter dvds
latest pc games
$words = file("$path/words.txt");
foreach ($words as $phrase){
if ((strpos($phrase, "shop")!== false) OR ((strpos($phrase, "store")!== false)){
$category = "shop";
}elseif(strpos($phrase, "dvd")!== false){
$category = "dvd";
}elseif ((strpos($phrase, "cd")!== false) OR ((strpos($phrase, "music")!== false)){
$category = "audio";
}elseif(strpos($phrase, "game")!== false){
$category = "game";
}
}else{
$category = "main";
}
echo "$phrase $catgeory";
}
All the (strpos($phrase, "$key")!==false) functions work perfectly if $phrase is defined as one variable eg.
$phrase = "shopping in new york";
if ((strpos($phrase, "shop")!== false) OR ((strpos($phrase, "store")!== false)){
$category = "shop";
}elseif(strpos($phrase, "dvd")!== false){
$category = "dvd";
}elseif ((strpos($phrase, "cd")!== false) OR ((strpos($phrase, "music")!== false)){
$category = "audio";
}elseif(strpos($phrase, "game")!== false){
$category = "game";
}
}else{
$category = "main";
}
echo "$phrase $category";
It's once I add the foreach loop to make this process repeat that the issues begin... I know very little about arrays really, so this possibly where the problems begin.
Thanks again for all your help, and if you got any suggestions, please let me know.
Regards
Matt