Folks,
This is valid array keys and valid array values:
““
$query_strings_array = array(
“find” => “keyword”,
“tbl” => “links”,
“col” => “keyword”,
“max” => “100”
);
They are actually params of a url.
And so, if the current page does not have these params in it’s query strings or the current page’s url has no query strings for that matter, then the current page is invalid. That’s what I want to check for.
So how to do it ?
I doing like this so far ….
““
//FETCH URL
if(isset($SERVER[‘HTTPS’]) && $SERVER[‘HTTPS’] === ‘on’)
{
$url = “https://”;
}
else
{
$url = “http://”;
}
// Append the host(domain name, ip) to the URL.
$url.= $_SERVER[‘HTTP_HOST’];
// Append the requested resource location to the URL
$url.= $_SERVER[‘REQUEST_URI’];
echo $url; echo ‘<br>’;
echo ‘<b>’ .__LINE__ .'</b>’; echo ‘<br>’;
if(filter_var($url, FILTER_VALIDATE_URL) && filter_var($url, FILTER_VALIDATE_URL, FILTER_FLAG_QUERY_REQUIRED))
{
$scheme = parse_url($url, PHP_URL_SCHEME);
$host = parse_url($url, PHP_URL_HOST);
$path = parse_url($url, PHP_URL_PATH);
$query_strings = parse_url($url, PHP_URL_QUERY);
//parse query into array
parse_str($query_strings, $query_strings_array2);
//separate keys & values
$query_strings_keys = array_keys($query_strings_array2);
$query_strings_values = array_values($query_strings_array2);
}
So now, I got the current page’s url saved in $url. And I got the query string params saved on these:
$query_strings_keys = array_keys($query_strings_array2);
$query_strings_values = array_values($query_strings_array2);
Now, how do I check the keys and values of $query_strings_array2 against $query_strings_array ?
This won’t do will it as I need to do the Boolean thingy here if I really want to compare two arrays …
[code]
if($result=array_diff_assoc($query_strings_arra1,$query_strings_array2))
{
echo ‘Array keys & values are Identical!’
}