Jump to content

[SOLVED] Manipulating a string.


Lamez

Recommended Posts

I have tried that, I get nothing.

 

<?php
  //begin checking for blacklisted...
        $n_url = $_SESSION['n_url'];

 	$par = parse_url($n_url);
	//print_r($par);
	 echo $par['path'];
	$b_url = $par['host'];//grab base url
	if($b_url = ""){
	 $b_url = $par['path'];
	}

	echo "Input URL: ".$n_url;
	echo "<br>";
	echo "Base: ".$b_url;
	echo "<br>";
	$www = addwww($b_url);
	echo "Add WWW: ".$www;
	echo "<br>";
	$pro = addPro($b_url);
	echo "Pro: ".$pro;
	echo "<br>";
	$both = addwww($b_url);
	$both = addPro($both);
	echo "Both: ".$both;
	echo "<br>";

        

  //end check, everything cleared...

?>

<?php
$url = 'http://www.youtube.com/watch?v=h0JX5jWv-tk';
print_r(parse_url($url));
?>

OUTPUT:
Array
(
    [scheme] => http
    [host] => www.youtube.com
    [path] => /watch
    [query] => v=h0JX5jWv-tk
)

 

['host'] is clearly correct.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.