Get second argument in php navigation
I am trying to grab the second argument of a URL such as this:
http://website.com/?p=2?id=ass92jdskdj92
I just want the id portion of the address. I use the following code to grab the first portion of the address:
$p = $_GET[p];
$remove = strrchr($p, '?');
$p = str_replace($remove, "", $p);
Any hints on how to get开发者_JAVA百科 the second portion?
Arguments in links are started by ?
and divided by &
.
That means your link should look like this:
http://website.com/?p=2&id=ass92jdskdj92
And you get them by:
$p = $_GET['p'];
$id = $_GET['id'];
First change the URL
only first argument start with ?
and rest of all is append by &
u should try with
echo parse_url($url, PHP_URL_PATH);
Reference:
parse url
精彩评论