I am trying to check if a URL has a specific query within a URL with multiple parameters:
$parts = parse_url('http://my url?queryA=valueA&queryB=valueB&queryC=valueC ....');
parse_str($parts['query'], $query);
I have used the below to get the value of the query;
$query['queryA']//outputs valueA
However, I want to check if "queryA" is indeed within the URL queries:
echo $parts['query'] // Outputs the full query - queryA=valueA&queryB=valueB&queryC=valueC
// Trying for
if($parts['query'] == 'queryA') {
// queryA is in the URL
}
isset()and not about parsing a url. Hardly a duplicate in my view, just because the accepted answer containsarray_key_exists()isn't related between both questions. Two different animals here. Plus, that other question doesn't even mentionparse_url(). Best to dig a bit deeper if you're going to mark a question as a duplicate. ;-)issetoverarray_key_exists, the OP is trying to determine if a variable exists before using it - therefore, this question shows little effort from the OP to search google and find the answer themselves. The duplicate does show how to test if a variable exists - it may not be 100% the same words but it certainly is 100% the same solution.