I want to look at a string and see if any of the words in the string match the words in a text file.
lets say i have a product.txt file and it contains:
apple sony dyson mcdonalds ipod
here is my code:
<?php
$productFile = file_get_contents('products.txt', FILE_USE_INCLUDE_PATH);
/*
* product.txt file contains
* apple
* pc
* ipod
* mcdonalds
*/
$status = 'i love watching tv on my brand new apple mac';
if (strpos($status,$productFile) !== false) {
echo 'the status contains a product';
}
else{
echo 'The status doesnt contain a product';
}
?>
right now its telling me the status doesnt contain a product which it does, can anyone see where im going wrong?