<tfoot id='kBEf6'></tfoot>
      <bdo id='kBEf6'></bdo><ul id='kBEf6'></ul>

      1. <small id='kBEf6'></small><noframes id='kBEf6'>

        <i id='kBEf6'><tr id='kBEf6'><dt id='kBEf6'><q id='kBEf6'><span id='kBEf6'><b id='kBEf6'><form id='kBEf6'><ins id='kBEf6'></ins><ul id='kBEf6'></ul><sub id='kBEf6'></sub></form><legend id='kBEf6'></legend><bdo id='kBEf6'><pre id='kBEf6'><center id='kBEf6'></center></pre></bdo></b><th id='kBEf6'></th></span></q></dt></tr></i><div id='kBEf6'><tfoot id='kBEf6'></tfoot><dl id='kBEf6'><fieldset id='kBEf6'></fieldset></dl></div>
        <legend id='kBEf6'><style id='kBEf6'><dir id='kBEf6'><q id='kBEf6'></q></dir></style></legend>

        循环遍历集合-Laravel

        时间:2023-09-22

        <small id='tQIyQ'></small><noframes id='tQIyQ'>

              <legend id='tQIyQ'><style id='tQIyQ'><dir id='tQIyQ'><q id='tQIyQ'></q></dir></style></legend>
              <i id='tQIyQ'><tr id='tQIyQ'><dt id='tQIyQ'><q id='tQIyQ'><span id='tQIyQ'><b id='tQIyQ'><form id='tQIyQ'><ins id='tQIyQ'></ins><ul id='tQIyQ'></ul><sub id='tQIyQ'></sub></form><legend id='tQIyQ'></legend><bdo id='tQIyQ'><pre id='tQIyQ'><center id='tQIyQ'></center></pre></bdo></b><th id='tQIyQ'></th></span></q></dt></tr></i><div id='tQIyQ'><tfoot id='tQIyQ'></tfoot><dl id='tQIyQ'><fieldset id='tQIyQ'></fieldset></dl></div>
              • <bdo id='tQIyQ'></bdo><ul id='tQIyQ'></ul>
                    <tbody id='tQIyQ'></tbody>
                  <tfoot id='tQIyQ'></tfoot>
                  本文介绍了循环遍历集合-Laravel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我试图遍历基于键的集合

                  我在这里想要完成的是根据我认为的字母表对每个公司进行分组.

                  What I am trying to accomplish here is to group each company based on the alphabet in my view.

                  我如何遍历这个??

                  $results = $companies->sortBy('name')->groupBy(function ($item, $key) {
                                   return substr($item['name'], 0, 1);
                          });
                  
                         dump($results);
                  

                  控制器

                  推荐答案

                  作为@msonowal 答案的替代方案,您还可以使用 each():

                  As an alternative to @msonowal's answer you can also use each():

                  $results->each(function ($collection, $alphabet) {
                      dump($alphabet, $collection);
                  });
                  

                  但是,如果您要在刀片文件中遍历它们,您可以使用:

                  However, if you're going to loop through them in a blade file you would use:

                  @foreach ($results as $alphabet => $collection)
                      {!! dump($alphabet, $collection) !!}
                  @endforeach
                  

                  https://laravel.com/docs/master/blade#loops

                  这篇关于循环遍历集合-Laravel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何在数据库的同一列中保存多个行的输入? 下一篇:如何从laravel eloquent unique中删除索引号

                  相关文章

                  最新文章

                    <tfoot id='lKBiy'></tfoot>

                    <i id='lKBiy'><tr id='lKBiy'><dt id='lKBiy'><q id='lKBiy'><span id='lKBiy'><b id='lKBiy'><form id='lKBiy'><ins id='lKBiy'></ins><ul id='lKBiy'></ul><sub id='lKBiy'></sub></form><legend id='lKBiy'></legend><bdo id='lKBiy'><pre id='lKBiy'><center id='lKBiy'></center></pre></bdo></b><th id='lKBiy'></th></span></q></dt></tr></i><div id='lKBiy'><tfoot id='lKBiy'></tfoot><dl id='lKBiy'><fieldset id='lKBiy'></fieldset></dl></div>
                      <bdo id='lKBiy'></bdo><ul id='lKBiy'></ul>

                    1. <small id='lKBiy'></small><noframes id='lKBiy'>

                    2. <legend id='lKBiy'><style id='lKBiy'><dir id='lKBiy'><q id='lKBiy'></q></dir></style></legend>