0
メニューをアルファベットでグループ化し、列で分割しようとしています。だから私は私の項目が既にアルファベットでソートされている連想配列を持っています。メニュー項目を列で並べ替える
foreach ($category['children'] as $children) {
$firstChar = $children['name'][0];
// if character is a number set it as #
if (is_numeric($firstChar)) {
$firstChar = "#";
}
if ($firstChar !== $previousChar) {
echo '<li class="submenu_tag">'.strtoupper($firstChar).'</li>';
$previousChar = $firstChar;
}
echo '<li><a href="'.$children['href'].'">'.$children['name'].'</a></li>';
$count++;
if ($count == 11) {
echo '</ul></div>';
echo '<div><ul>';
$count = 0;
}
}
echo '</ul></div>';
私は今これを出力します。
<div> <div> <div>
A Cow Fawn
Apple Crab Fish
Ape Fox
Ant D
Dog G
B Gazette
Boy E Goose
Ball Elephant Gorilla
Bad Egg
Elk H
C Hedgehog
Camel F Hen
Cat Falcon
</div> </div> </div>
所望の結果は、グループに属し、以下のいくつかの項目は、(間の空きスペースを除く)11行を超えて起こっている場合、それは新たなDIVにそれを移動するであろう。このような何か:
<div> <div> <div>
A C F
Apple Cat Falcon
Ape Cow Fawn
Ant Crab Fish
Fox
B D
Boy Dog G
Ball Gazette
Bad E Goose
Elephant Gorilla
Egg
Elk .....
</div> </div> </div>
サンプル入力できますか? –
その '$ children ['id']' '$ children ['name']'と '$ children ['href']' – John