Skip to content Skip to sidebar Skip to footer

Php To Compare And Return A Variable In A Querystring

I need a bit of simple PHP code that can return a specified variable if any one of three variables is contained within a query string. Probably easier to explain like this: if {que

Solution 1:

functionevaluateThis($var1,$var2,$var3) {
   if((strpos($string,$var1) !== false) || (strpos($string,$var1) !== false) || (strpos($string,$var1) !== false)) {
       return$var1;
   }
   else { return'string not found'; }
 }

Is this what you mean

Solution 2:

If you want to analyse the query string of the current request:

array_search($var1,$_GET)!==false OR array_search($var2,$_GET)!==false ....

else:

$vars = array();
parse_string($queryString,$vars);
if(array_search($var1,$vars)!==falseOR array_search($var2,$vars)!==false ...

.

Post a Comment for "Php To Compare And Return A Variable In A Querystring"