Revision: 16349
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at August 1, 2009 01:52 by jlvallelonga
Initial Code
function formatWebAddress($webAddress) {
$originalWebAddress = $webAddress;
$webAddress = "*" . $webAddress;
$formattedWebAddress = "";
if (stripos($webAddress, "http://") == 1) { //starts with http://
if (substr_count($webAddress, ".") == 1) { //one dot only
$formattedWebAddress = $originalWebAddress;
$formattedWebAddress = insertString($formattedWebAddress, "www.", 7);
}
else
$formattedWebAddress = $originalWebAddress;
}
else { //does not start with http://
if (substr_count($webAddress, ".") == 1) //one dot only
$formattedWebAddress = "http://www." . $originalWebAddress;
elseif (substr_count($webAddress, ".") >= 2) //two dots only
$formattedWebAddress = "http://" . $originalWebAddress;
else
$formattedWebAddress = $originalWebAddress;
}
// add slash at end
if (substr_count($formattedWebAddress, "/") == 2) //if it has "//" at beginning
$formattedWebAddress .= "/";
$formattedWebAddress = strtolower($formattedWebAddress);
return $formattedWebAddress;
}
Initial URL
http://justpushbuttons.com/examples/format_web_address_example.php
Initial Description
this function formats a web address for use in a link.<br>
echo formatWebAddress("google.com");<br>
http://www.google.com/
Initial Title
formatWebAddress
Initial Tags
url, format, link, web
Initial Language
PHP