/ Published in: PHP

this function formats a web address for use in a link.
echo formatWebAddress("google.com");
http://www.google.com/
echo formatWebAddress("google.com");
http://www.google.com/
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function formatWebAddress($webAddress) { $originalWebAddress = $webAddress; $webAddress = "*" . $webAddress; $formattedWebAddress = ""; $formattedWebAddress = $originalWebAddress; $formattedWebAddress = insertString($formattedWebAddress, "www.", 7); } else $formattedWebAddress = $originalWebAddress; } else { //does not start with http:// $formattedWebAddress = "http://www." . $originalWebAddress; $formattedWebAddress = "http://" . $originalWebAddress; else $formattedWebAddress = $originalWebAddress; } // add slash at end $formattedWebAddress .= "/"; return $formattedWebAddress; }
URL: http://justpushbuttons.com/examples/format_web_address_example.php
Comments
