1

I need to get url value form the given url string, for example I have below url

$url = http://www.example.com/news?q=string&f=true&id=1233&sort=true&pf=http%3A%2Fo%2fox.ru

from above url if any url is present means I need that value, above is not constant, randomly I get any format of url , But I need only the url from the given URL string.I reffered here How to get parameters from a URL string?. In that they use static parameter , but I dont know which parameter have the url value. Any help is appreciated.

Thiyagu
  • 746
  • 3
  • 11
  • 29

2 Answers2

2

solved your issue please check this code it will help you more

<?php
$url = "http://www.example.com/news?q=string&f=true&id=1233&sort=true&pf=http%3A%2Fo%2fox.ru";
$total_part = parse_url($url);
parse_str($total_part['query'], $query);
foreach ($query as $key => $value) {
    echo $key.'=>'.$value."<br>";
}
?>
any further help i am available here
Niraj patel
  • 525
  • 4
  • 12
2
<?php
$url = "http://www.example.com/news?q=string&f=true&id=1233&sort=true&pf=http%3A%2Fo%2fox.ru";
parse_str(parse_url($url, PHP_URL_QUERY), $output);
echo print_r($output, TRUE);
?>

You can also use this code.

sunakshi verma
  • 141
  • 1
  • 8