Hi,
im having a problem with the regex function preg_match. Im trying to extract certain bits from strings, but im getting a compilation error.
Heres the code:
<?php
$host[0] = "http://www.emcb.co.uk/uk/search/products/index.php?query=DBforum";
$host[1] = "http://www.emcb.co.uk/uk/help/index.php?query=internet faqs&bool=1";
$host[2] = "https://www.emcb.co.uk/login/check.php";
echo "<PRE>\n";
foreach( $host as $key => $value )
{
if( preg_match("/?(:\/\/)/i", $value, $matchdata) )
{
$server_protocol = strtoupper($matchdata[0]);
$server_name = str_replace("http://", "", $host[$key]);
if( !preg_match("/www/i", $server_name, $matchdata) )
{
$domain_name = str_replace("www.", "", $server_name);
$name_split = str_replace($domain_name, "", $domain_name);
$name_split = explode("?", $name_split);
}
else
{
$domain_name = $server_name;
$name_split = str_replace($domain_name, "", $domain_name);
$name_split = explode("?", $name_split);
}
$request_uri = $name_split[0];
$query_string = $name_split[1];
echo " <tr>
<td width=\"100%\"><div align=\"left\"><font face=\"Verdana\" size=\"2\">
<b>Server Protocol:</b> $server_protocol<br>
<b>Server Name:</b> $server_name<br>
<b>Domain Name:</b> $server_protocol<br>
<b>Request URI:</b> $server_protocol<br>
<b>Query String:</b> $server_protocol<br>
</font></div></td>
</tr>";
}
}
?>
the first match gets the protocol.
the second sees if theres a www. in the str.
the third tells if is a subdomain of mine.
its only used on my domains which all have a two-part domain suffix.
Anyone know whats wrong?
Cheers,
Elfyn