Dear Reader,
I would like to make a script which adds http:// to an url when the users gives www.cnn.com or home.planet.nl
but it doesn't need to put http:// if it allready exists.
How to fix it?
Gr.
Kasper (17yr)
$url="www.cnn.com"; if(ereg("http://", $url)){ print $url; } else{ $url="http://".$url; print $url; }
Dear Peio,
Thank you, Thank you, very very much. The script works fine.
Kasper
the second line of your solution script has a "" left of "http". I was wondering what that did, why it needs to be there. Is it part of the string that it checks, or a special character describing the location of the string??
~Just curious
the second 🙂 http://www.phpbuilder.com/columns/dario19990616.php3 and your best friend - The Manual http://www.php.net/manual/en/function.ereg.php