samedi 30 avril 2016

PHP Check if specific query is in url

I am trying to check if a url has a specific query within a url with multiple params

$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
}

Aucun commentaire:

Enregistrer un commentaire