Reputation: 309
I am just beginning PHP and I am very confused
say
www.blablabla.com/phpfile.php?=this_is_a_test
I want to create a new string from text after the ?=
So in this case the string would be "this_is_a_test"
how would I do this?
Upvotes: 2
Views: 97
Reputation: 7805
Use parse_url:
$parsed = parse_url($url);
echo substr($parsed['query'], 1);
Output:
this_is_a_test
If you have multiple variables in the query, you can parse them like in the following example:
$url = 'www.blablabla.com/phpfile.php?foo=bar&baz=boom';
$parsed = parse_url($url);
parse_str($parsed['query'], $out);
print_r($out);
Output:
Array
(
[foo] => bar
[baz] => boom
)
Upvotes: 1
Reputation: 4079
Here is the example:
$url = 'www.blablabla.com/phpfile.php?=this_is_a_test';
print_r(parse_url($url));
Upvotes: 2