title: Detecting a url using preg_match? without http:// in the string
body: <p>I was wondering how I could check a string broken into an array against a preg_match to see if it started with www. I already have one that check for <a href="http://www">http://www</a>. </p>
  
  <pre><code>function isValidURL($url)
  {
  return preg_match('|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $url);
  }
  
  $stringToArray = explode(" ",$_POST['text']);
  
    foreach($stringToArray as $key=&gt;$val){
    $urlvalid = isValidURL($val);
    if($urlvalid){
    $_SESSION["messages"][] = "NO URLS ALLOWED!";
    header("Location: http://www.domain.com/post/id/".$_POST['postID']);
       exit();
       }
       }
  </code></pre>
  
  <p>Thanks!
  Stefan</p>