This is what I have so far. Hopefully it's a start in the right direction.
Code: Select all
// id is simply a number, and url will be these:
// http://google.com/
// http://www.apple.com/
// http://ryan.com/
// http://air.com/
// http://www.green.com/
$query = mysql_query("SELECT id, url FROM websites");
while($r = mysql_fetch_array($query)) {
$url = $r["url"];
$url = substr_replace(substr_replace($url, "", -1), "", 0, 7); // removes the http:// and the trailing slash from each url
if(substr($url, 0, 4) == "www.") { // checks for 'www.'
$sites[$r["id"]] = array(substr_replace($url, "", 0, 4), "www.");
} else {
$sites[$r["id"]] = array($url, "");
}
}[3] => air.com
[1] => http://www.apple.com
[0] => google.com
[4] => http://www.green.com
[2] => ryan.com
NOTE: The formatting this forum uses is adding the http prefix onto [1] and [4] in the list above. I just want www[.]apple.com and www[.]green.com without http in front of it.