ここで重複に少し問題があります。重複の戻り値が最大の int 値のままである限り、いつでも重複をクリップできると思います。
コードスタンプは次のとおりです。
$unitList = Base_Client_Model::getBusinessUnitList(false, $selectedMarket, false, true);
$marketListBox = $marketOptions = '';
$marketList = array();
for ($x = 1; $x <= $unitList['NUMBER_OF_BUSINESS_UNITS']; $x++) {
$unitStr = 'BUSINESS_UNIT_' . $x . '_';
$businessUnit = Base_Client_Model::getBusinessUnit($unitList[$unitStr . 'ID']);
if ($unitList[$unitStr . 'ID'] && $unitList[$unitStr . 'ID'] != 42) {
$marketListBox = "<option value='" . $unitList[$unitStr . 'ID'] . "'";
if($selectedMarket == $unitList[$unitStr . 'ID']) {
$marketListBox .= ' selected';
$selectedMarket = 0;
}
$marketListBox .= "> " . preg_replace('/-Wimax/i', '', $unitList[$unitStr . 'NAME']) . "</option>\n";
$marketList[$businessUnit->getElement('STATE')][] = $marketListBox;
}
}
ksort($marketList);
foreach($marketList as $key => $val) {
$marketOptions .= "<option disabled='disabled'> </option><option disabled='disabled'>{$key}¬</option>\n" . implode($val);
}
$this->view->marketOptions = $marketOptions;
リターンの例を次に示します。
<option disabled="disabled"> </option><option disabled="disabled">WA¬</option>
<option value="56"> Aberdeen</option>
<option value="82"> Bellingham</option>
<option value="106"> Everett</option>
<option value="109"> Kitsap County</option>
<option value="102"> Seattle</option>
<option value="105"> Tacoma</option>
<option value="20"> Tri-Cities</option>
<option value="173"> Tri-Cities</option>
<option value="64"> Wenatchee</option>
<option value="65"> Yakima</option>
<option value="162"> Yakima</option>
期待される出力は次のとおりです。
<option disabled="disabled"> </option><option disabled="disabled">WA¬</option>
<option value="56"> Aberdeen</option>
<option value="82"> Bellingham</option>
<option value="106"> Everett</option>
<option value="109"> Kitsap County</option>
<option value="102"> Seattle</option>
<option value="105"> Tacoma</option>
<option value="173"> Tri-Cities</option>
<option value="64"> Wenatchee</option>
<option value="162"> Yakima</option>
答えはこれに似たものだと思います
$unitList['BUSINESS_UNIT_' . $x . '_NAME'] != $unitList['BUSINESS_UNIT_' . $x + 1 . '_NAME']