Warning: Invalid argument supplied for foreach()
function cs_take_location()
{
list ($location, ) = explode(".",getenv("HTTP_HOST"));

$locations = cs_get_locations(false);

foreach ($locations['citynames'] as $cityname=>$city)
{
if ($cityname == $location)
{
global $xcityid;
return $city[0];
}
}

foreach ($locations['countrynames'] as $countryname=>$countryid)
{
if ($countryname == $location)
{
return -$countryid;
}
}
}
pls help me to solve this problem