Php Flow » Php

How To Parse STRING In PHP

In pervious tutorial I was told you how to parse URL, Now I want to share next steps, how to parse query string in PHP. In Previous tutorial you have below Array.

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.

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

Did you enjoy this article? Share it!

About the Author:

Hi, This is Parvez Alam from India. I am software developer with 4 years’ experience in web development. I have submitted articles on PHP, Mysql, Magento,CSS, HTML, jQuery, web designing and social API. You can subscribe to my blog via RSS/Twitter/Google plus and Facebook. parvez1487(at)gmail(dot)com

Also like

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>