3

validatewebsite

validate_website
SYNOPSIS

validate_website($url)

DESCRIPTION
CODE
  1. function validate_website($url) {
  2.     return preg_match('#^(http(s)?://)?(www\.)?(([^\.]+)\.)+[a-z]{2,}$#', $url);
  3. }
normalize_website
SYNOPSIS

normalize_website($url)

DESCRIPTION
CODE
  1. function normalize_website($url) {
  2.     return preg_replace('#^(http(s)?://)?((www\.)?([^\.]+)\.[a-z]{2,})$#', '\3', $url);
  3. }

Comments

To add a comment, click here.