Concaténation de deux tableaux
Bonjour,
je reviens avec le probléme de concaténation de tableaux, aprés avoir réussi la concaténation des tableaux en un seul je me suis confronté a un probléme c'est la répétition des éléments .
voici la fonction qui récuépre les pays et fait la concaténation:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
function getCountriesList(){
$client = new VoxAPIClient('http://sandbox.voxbone.com/VoxAPI/services/VoxAPI?wsdl', true);
$token = getToken();
$request = new GetCountriesListRequest( $token );
$request->setDIDType('GEOGRAPHIC');
$geographic = $client->getCountriesList( $request );
/*echo '<pre>';
print_r($geographic);
echo '</pre>';*/
$token = getToken();
$request= new GetCountriesListRequest( $token );
$request->setDIDType('NATIONAL');
$national= $client->getCountriesList( $request );
$response= array_merge($geographic, $national);
//$response =array_unique($array);
return $response;
/*echo '<pre>';
print_r($client->debug());
echo '</pre>';
*/
echo '<pre>';
print_r($response);
echo '</pre>';
return $response;
} |
et le script qui fait l'affichage:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
<form action="./index.php">
<?php
$countriesList = getCountriesList();
?>
<select name="CountryID" onChange="submit();">
<?php
if( !isset( $_GET['CountryID'] ) ){
echo "<option value=-1>------------------------------</option>";
}
foreach( $countriesList as $country ){
$opt = "<option value=$country->CountryID";
// default value is the selected value
if( isset( $_GET['CountryID'] ) && $_GET['CountryID'] == $country->CountryID ){
$opt = $opt." SELECTED>";
}else{
$opt = $opt.">";
}
$opt = $opt."$country->CountryName (+$country->CountryCode)</option>";
echo $opt;
}
?>
</select>
</form> |
Pour rappel les élément sont récupérer depuis un serveur via l'API SOAP