Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Format Web Address
#1
Credits and Source: http://www.roscripts.com/

Name: Format Web Address
Description: This function formats a web address for use in a link.
Snippet:

PHP 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;



Thankyou for reading. Be happy always Smile
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Your IP Address in Colour Jamza 7 1,830 10-28-2009, 02:53 AM
Last Post: Bartdevil

Forum Jump:


Users browsing this thread: 1 Guest(s)