在结果中,下拉菜单中有一些重复的内容。你知道如何解决吗?
购买array_unique
吗?
谢谢
示例:
<select name="boxtal_operator" id="sortDropDownListByText" class="form-control">
<option value="0">--- Select ---</option>
<option value="CHRP-1456S">AGAY / L'ATELIER FLORAL D'AGAY / 125 BD DE LA PLAGE / CHRP-1456S</option>
<option value="CHRP-1456S">AGAY / L'ATELIER FLORAL D'AGAY / 125 BD DE LA PLAGE / CHRP-1456S</option>
<option value="CHRP-1456S">AGAY / L'ATELIER FLORAL D'AGAY / 125 BD DE LA PLAGE / CHRP-1456S</option>
<option value="SOGP-I3171">AGAY / PROXI / 1318 BD DE LA 36EME DI DU TEXASLE DRAMONT / SOGP-I3171</option>
<option value="SOGP-I3171">AGAY / PROXI / 1318 BD DE LA 36EME DI DU TEXASLE DRAMONT / SOGP-I3171</option>
<option value="SOGP-I3171">AGAY / PROXI / 1318 BD DE LA 36EME DI DU TEXASLE DRAMONT / SOGP-I3171</option>
</select>
下面的php代码允许产生此结果。
$operator_code = ['POFR', 'MONR', 'SOGP', 'Chrono', 'CHRP', 'IMXE', 'UPSE', 'PUNT'];
$result_carrier_code[] = ['id' => '0', 'text' => Core::getDef('text_select')];
foreach ($operator_code as $operator)
{
$list_point = $this->boxtaleShop->getListPoint($country_iso, $code_postal, $city, $operator);
foreach ($list_point as $carrier)
{
if (is_array($carrier)) {
foreach ($carrier as $item)
{
if (is_array($item['points'])) {
foreach ($item['points'] as $points)
{
if (is_array($points)) {
$result_carrier_code[] = [
'id' => $points['code'],
'text' => $points['city'] . ' / ' . $points['name'] . ' / ' . $points['address'] . ' / ' . $points['code']
];
}
}
}
}
}
}
}
数组示例(很大)
array(496) { [0]=> array(2) { ["id"]=> string(1) "0" ["text"]=> string(14) "--- Select ---" } [1]=> array(2) { ["id"]=> string(10) "MONR-08915" ["text"]=> string(57) "FREJUS / CULTURE INDOOR / ROUTE DE MALPASSET / MONR-08915" } [2]=> array(2) { ["id"]=> string(10) "MONR-06124" ["text"]=> string(57) "FREJUS / CULTURE INDOOR / ROUTE DE MALPASSET / MONR-06124" } [3]=> array(2) { ["id"]=> string(10) "MONR-05847" ["text"]=> string(63) "FREJUS / OLI'VAP / 2040 RUE DES COMBATTANTS D'AFRI / MONR-05847" } [4]=> array(2) { ["id"]=> string(10) "MONR-03415" ["text"]=> string(79) "BAGNOLS EN FORET / CARREFOUR CONTACT / DEPARTEMENTAL 4 LA ROUVIERE / MONR-03415" } [5]=> array(2) { ["id"]=> string(10) "MONR-05850" ["text"]=> string(53) "FREJUS / SOS PHONE / 169 RUE JEAN JAURES / MONR-05850" } [6]=> array(2) { ["id"]=> string(10) "MONR-94030" ["text"]=> string(88) "FREJUS / FITNESS BOUTIQUE FREJUS / 129 RUE ALERT EINSTEIN, FACE A DAFY MOTO / MONR-94030" } [7]=> array(2) { ["id"]=> string(10) "MONR-99539" ["text"]=> string(75) "SAINT-RAPHAEL / WELDOM ST RAPHAEL / 1205 BOULEVARD JEAN MOULIN / MONR-99539" } [8]=> array(2) { ["id"]=> string(10) "MONR-04322" ["text"]=> string(78) "ST RAPHAEL / AVADI BOUTIQUE CADEAU / 80 AVENUE DU GENERAL LECLERC / MONR-04322" } [9]=> array(2) { ["id"]=> string(10) "MONR-03980" ["text"]=> string(68) "ST RAPHAEL / PHARMACIE DES GENETS / 1416 BD JEAN MOULIN / MONR-03980" } [10]=> array(2) { ["id"]=> string(10) "MONR-03457" ["text"]=> string(55) "FREJUS / COLOR-LAB / 229 RUE ROLAND GARROS / MONR-03457" } [11]=> array(2) { ["id"]=> string(10) "MONR-63070" ["text"]=> string(73) "PUGET SUR ARGENS / AGENCE MONDIAL RELAY / 577 BD DU COMMERCE / MONR-63070" } [12]=> array(2) { ["id"]=> string(10) "MONR-04715" ["text"]=> string(92) "FREJUS / MINERAUX & MERVEILLES / 362 RUE VICTOR REYBAUD, SQUARD LIBERATION PARK / MONR-04715" } [13]=> array(2) { ["id"]=> string(10) "MONR-12297" ["text"]=> string(60) "FREJUS / TABAC PRESSE / 355 RUE HIPPOLYTE FABRE / MONR-12297" } [14]=> array(2) { ["id"]=> string(10) "MONR-04478" ["text"]=> string(61) "STRAPHAEL / EPICERIE / 144 BD GEORGES CLEMENCEAU / MONR-04478" }