How to display an Array under alphabetical letters using PHP?

后端 未结 6 1983
傲寒
傲寒 2021-02-04 17:06

I have an array that already contains all it\'s values in alphabetical order:

Alligator
Alpha
Bear
Bees
Banana
Cat
Cougar

Now I just want to li

6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-04 17:27

    For HTML output:

    A

    1. tag count Animal
    2. tag count Aqua
    3. tag count Arthur

    C

    1. tag count Camel
    2. tag count Crazy

    I change Artefact2 code and share for you

     $tag) { 
            $firstLetter = strtoupper(substr($tag['name'], 0, 1));
            if($previous !== $firstLetter) { 
                if($key != 0) {
                    echo '';
                }?>
                

    1. '; } $previous = $firstLetter; } ?>

    Best Regards www.Forum.iSYSTEMS.am

提交回复
热议问题