PHP - Search array in array
- by Anonymous2011
I have tried googling for the past one hour straight now and tried many ways to search for an array, in an array.
My objective is, to find a keyword in the URL, and the keywords are in a txt file.
This is what i have so far - but doesn't work.
$file = "keywords.txt";
$open = fopen($file,'r');
$data = fread($open,filesize($file));
$data = explode(" ",$data);
$url = (!empty($_SERVER['HTTPS'])) ? "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] : "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
$url = parse_url($url); //parse the URL into an array
foreach($data as $d)
{
if(strstr($d,$url))
{
echo "yes";
}
}
This works WITHOUT the text file, or array - but that's not what i want.
I'd appreciate it if anyone can assist me.