0

I am trying to create website, now i m facing some problems like.

  1. Get the all the arguments in one array in php
  2. Get the full url with all the arguments.
  3. In my url, i have sent two different values by one key name. How I will get all the values and corresponding keys. Like...

    http://localhost:8082/file:/C:/Users/Nitz/Desktop/NEw%20Ryt/LOCAL%20-%20website/data.php?Company=YouBroadband&Company=YouBroadband&Company=Vodafone&Company=YouBroadband&Company=Vodafone&Company=Tata Photon Plus&Company=YouBroadband&Company=Vodafone&Company=Tata Photon Plus&Company=Tata Photon

the function is performing some task on database also, so i wanted both key and there values. AND yes, I wanted to do this work in PHP.

Please any ideas !!!!

3
  • 1
    than why do you have a JavaScript tag if you want it in php? Commented Mar 16, 2012 at 1:28
  • 2
    The url data goes into $_GET. You should var_dump($_GET) to see what it contains... Commented Mar 16, 2012 at 1:34
  • @epascarello - ask and you shall receive. I updated the tags. Commented Mar 16, 2012 at 1:53

2 Answers 2

1
  1. $_REQUEST will contain all GET and POST parameters, $_GET will contain only get and $POST will contain only post. One of these is the array you are looking for.

  2. This will give you your full URL

    $myURL = 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST URI'];

  3. Here's some example code to get all values:

    foreach ($_REQUEST as $key => $value) { // $key is your your key like Company // $value would be the corresponding value like YouBroadband }

Sign up to request clarification or add additional context in comments.

2 Comments

yaa i have tried that code but its not getting second time company.. :(
Going by memory (and this has been a long time, so I'm sorry if it's wrong) try something like: if (is_array($value)) { if ($key == 'Company') { doSomething(); } }
0

You can use a combination of parse_url and parse_str

$queryString = parse_url($url);
$queryString = $queryString['query'];

$args = array();
parse_str($queryString, $args);

print_r($args);

http://www.php.net/manual/en/function.parse-str.php

http://php.net/manual/en/function.parse-url.php

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.