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?