PHP - Search array in array

Posted by Anonymous2011 on Stack Overflow See other posts from Stack Overflow or by Anonymous2011
Published on 2011-05-30T22:08:58Z Indexed on 2012/06/11 22:40 UTC
Read the original article Hit count: 151

Filed under:
|
|

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.

© Stack Overflow or respective owner

Related posts about php

Related posts about arrays