I need some help with PHP array_unique. In my code below, it works on every result except Bangladesh, Pakistan, Egypt, and India. Furthermore, it puts a few countries out of order on the top of the list. Help?
$params = array();
$params['in'] = '?';
ini_set("soap.wsdl_cache_enabled", "0");
$client = new SoapClient("http://apollov-dev.worlddata.com/WrapSystem/services/FactoriesWS?wsdl",array("trace" => 1, "exceptions" => 0));
$monitorResult=$client->allActiveMonitors($params);
$countryList=array();
foreach($monitorResult->response as &$country)
{
$countryArray=array();
if(isset($country->accreditedCountries))
{
if(strpos($country->accreditedCountries,", ")!== false)
{
$countryArray=explode(",",$country->accreditedCountries);
}
else
{$countryArray[]=$country->accreditedCountries;}
foreach($countryArray as $value)
{
if(in_array($value,$countryList)==false)
{$countryList[]=$value;}
else {}
}
}
else {}
}
$newArray=$countryList;
asort($newArray);
array_unique($newArray);
foreach($newArray as $record)
{
echo $record;
echo "<br/>";
}
$newArray
, don't force us all to make a soap request to see what you're seeing – Mark Baker Jan 10 at 17:30