nasty
nasty

Reputation: 7077

Get parameter values of a URL in a string variable PHP

I have this url in a string. This is not the current page URL, but it's in a string store for me to access.

$query_string = 'Itemid=364&option=com_easyblog&id=2&view=entry';

I know we can use $_GET["fname"] to get the valued of option and id etc if it's in the URL. But I don't know how to look for the option value if the url is in a string.

I tried strpos($query_string, 'com_easyblog') != FALSE to see if com_easyblog exists in the URL, it works fine. But When it come to checking the id I'm stuck. Can you guys help?

Upvotes: 0

Views: 1873

Answers (2)

Jan Tojnar
Jan Tojnar

Reputation: 5524

You want to parse query string (parse_str function)

Upvotes: 2

Damp
Damp

Reputation: 3348

This is probably what you're looking for http://php.net/manual/en/function.parse-str.php

Upvotes: 2

Related Questions