How to get the value of a query string STRING using php

Suppose I have a line like this:

rajeshpatel&rid=10&sid=20&mid=30

      

Then how can I get the value "rid"

using php.

any help?

+3


source to share


1 answer


You can use parse_str

like

$str = 'rajeshpatel&rid=10&sid=20&mid=30';
parse_str($str,$result);
print_r($result);
echo $result['rid'];//10

      

Or you can use it in another way like



parse_str($str);
echo $rid;//10

      

Fiddle

+1


source







All Articles