Php正则表达式:需要一些解释

I was experimenting with regexps last day and the following code gave me quite an unexpected result

<?php
// get host name from URL
if (preg_match("/^(http:\/\/)?([^\/]+)/i", "http://", $matches)) {
    $host = $matches[1];
    echo $host."<br/>";
}
else
    echo "Not Found";
?>

The result was a blank line. Can anyone explain why it is so? I was expecting it to print 'http://' as it is the first match and as I expected, matches[0] does print 'http://' so why is the null character being printed first?

/^(http:\/\/)?([^\/]+)/i

http:// is optional and 'not /' is not.

Therefore, when it goes to match it, it will see that it cannot match it if it applies the optional rule first, but it can match it if applies the one or more not / rule.

In other words, it is matching http: instead of http:// because http: is not /.

array(3) {
  [0]=>
  string(5) "http:"
  [1]=>
  string(0) ""
  [2]=>
  string(5) "http:"
}