How To Parse STRING In PHP

PHP is using parse_str function to parse string, In previous tutorial we have learned how to parse URL, Now I want to share next steps, how to parse query string in PHP.We are taking sample below Array.

You can also check other tutorial of string,

Select Code
1
2
3
4
5
6
7
Array
(
    [scheme] => https
    [host] => graph.facebook.com
    [path] => /xxxxxx/feed
    [query] => limit=400&until=1353532418
)


If you want to get out until parameter value, how to do it, first one option we will use explode() function second one we use PHP inbuilt simple parse_str() method.

How to Parse Query String from URL Using PHP

Select Code
1
2
3
4
5
6
$nexUrl = 'https://graph.facebook.com/xxxxxx/feed?limit=400&until=1353532418';
$parseURL = parse_url($nexUrl);
echo "<pre>";
print_r($parseURL);
parse_str($parseURL['query']);
echo 'limit='. $limit .'<br/> until='.$until;

Result:

parse_string