Reputation: 1273
I have a couple of url strings like below:
admin.php?filter_status=New
admin.php?filter_status=New¤tpage=2
and
admin.php?entry_search=Ready
admin.php?entry_search=Ready¤tpage=3
How can i grab always the value between ?
and &
?
So: entry_search=Ready
or filter_status=New
In case the url is" admin.php?entry_search=Ready¤tpage=3
;
$_SERVER['QUERY_STRING']
gives me entry_search=Ready¤tpage=3
and it should always give me only entry_search=Ready
Upvotes: 1
Views: 280
Reputation: 78994
It will be the first in the $_GET
superglobal, so:
$val = reset($_GET);
$key = key($_GET);
To use the query string:
parse_str($_SERVER['QUERY_STRING'], $array);
$val = reset($array);
$key = key($array);
If you really need a string then:
$result = "$key=$val";
Upvotes: 1