1

I have one URL string like

'http://example.com/glamour/url.php?ad_id=[ad_id]&pubid=[pubid]&click_id=[click_id]'

So I want to fetch value of all parameters which mentioned in []. Like ad_id,pubid,clickid

How can I fetch values of parameters?

1
  • I use: print_r($_GET); Commented Jan 30, 2017 at 13:05

3 Answers 3

2
<?php
   echo $_GET['ad_id']; // ad_id is the name of parameter.
?>

This code will give you the value of parameter

For String of URL try this :

$parts = parse_url($url);
parse_str($parts['query'], $query);
echo $query['ad_id'];
Sign up to request clarification or add additional context in comments.

1 Comment

I have string of URL. So I can not use this. I want to fetch it from string of URL.
0

You could use this command.

 print_r($_GET);

And then you could see the all parameters in the url.

1 Comment

I have string of URL. So I can not use this. I want to fetch it from string of URL.
0

Use this simple code to get all parts of query:

<?php
    /* Parse url */
    $url = 'http://example.com/url.php?ad_id=[ad_id]&pubid=[pubid]';
    parse_str( parse_url( $url, PHP_URL_QUERY ), $query_data );

    /* Results */
    var_dump($query_data['ad_id']);
    var_dump($query_data['pubid']);
?>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.