What I am trying to do is a 'network sites' links where all the network sites are in an array and after each network site there is a ',' except the last one (because it is the last item of the list) so say the current site was google.com
$all_sites = array('google.com','exaple.com','test.info','site.com','text.com');
what i want to do is
if $_SERVER['HTTP_HOST'] = $array['google.com'] then to take google.com out of the array so there are only 4 other sites left in the array.. I tried doing it like this
function network_sites(){
global $all_sites;
global $site_url;
$number_of_links = 4;
shuffle($all_sites);
for ($i=0; $i<$number_of_links; $i++) {
$capitalize = ucfirst($all_sites[$i]);
if ($all_sites[$i] != $site_url){
$last_site = $number_of_links - 1;
if ($last_site == $i){
echo '<a href="http://'.$all_sites[$i].'/">'.$capitalize.'</a>';
}else{
echo '<a href="http://'.$all_sites[$i].'/">'.$capitalize.'</a>, ';
}
}
}
}
but sometimes the last site has a comma in the end.. and it displays only 3 network sites (when its supposed to show 4) most of the time because if ($all_sites[$i] != $site_url) is being true and just doing nothing.
Exaple.com, Test.info, Site.com,
I think it would be easier and faster to just tackle the exporting before the function is needed but I couldn't find anything on how to completely take out a value of an array so it doesn't exist any more.
Thanks