Rahul Rahul - 4 months ago 7
PHP Question

PHP to get element from link

I have below code:-

$link = 'http://www.domain.com/go.php?id=545&url=http://www.example.com/about


I want URL element that is - http://www.example.com/about

Answer
$link = 'http://www.domain.com/go.php?id=545&url=http://www.example.com/about';

$url = explode("&url=", $link)[1];
echo $url; //http://www.example.com/about
Comments