久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

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

    <bdo id='ADY1K'></bdo><ul id='ADY1K'></ul>

      <legend id='ADY1K'><style id='ADY1K'><dir id='ADY1K'><q id='ADY1K'></q></dir></style></legend>
      <tfoot id='ADY1K'></tfoot>
    1. <i id='ADY1K'><tr id='ADY1K'><dt id='ADY1K'><q id='ADY1K'><span id='ADY1K'><b id='ADY1K'><form id='ADY1K'><ins id='ADY1K'></ins><ul id='ADY1K'></ul><sub id='ADY1K'></sub></form><legend id='ADY1K'></legend><bdo id='ADY1K'><pre id='ADY1K'><center id='ADY1K'></center></pre></bdo></b><th id='ADY1K'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='ADY1K'><tfoot id='ADY1K'></tfoot><dl id='ADY1K'><fieldset id='ADY1K'></fieldset></dl></div>
    2. 使用用戶定義函數搜索 PHP 數組的優雅方式

      Elegant way to search an PHP array using a user-defined function(使用用戶定義函數搜索 PHP 數組的優雅方式)

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

        • <tfoot id='R9UDL'></tfoot>
        • <i id='R9UDL'><tr id='R9UDL'><dt id='R9UDL'><q id='R9UDL'><span id='R9UDL'><b id='R9UDL'><form id='R9UDL'><ins id='R9UDL'></ins><ul id='R9UDL'></ul><sub id='R9UDL'></sub></form><legend id='R9UDL'></legend><bdo id='R9UDL'><pre id='R9UDL'><center id='R9UDL'></center></pre></bdo></b><th id='R9UDL'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='R9UDL'><tfoot id='R9UDL'></tfoot><dl id='R9UDL'><fieldset id='R9UDL'></fieldset></dl></div>
            <tbody id='R9UDL'></tbody>

          <legend id='R9UDL'><style id='R9UDL'><dir id='R9UDL'><q id='R9UDL'></q></dir></style></legend>
                <bdo id='R9UDL'></bdo><ul id='R9UDL'></ul>
                本文介紹了使用用戶定義函數搜索 PHP 數組的優雅方式的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                基本上,我希望能夠獲得 C++ 的 find_if()、Smalltalk 的 detect: 等的功能:

                Basically, I want to be able to get the functionality of C++'s find_if(), Smalltalk's detect: etc.:

                // would return the element or null
                check_in_array($myArray, function($element) { return $elemnt->foo() > 10; });
                

                但我不知道有任何 PHP 函數可以做到這一點.我想出的一個近似值":

                But I don't know of any PHP function which does this. One "approximation" I came up with:

                $check = array_filter($myArray, function($element) { ... });
                if ($check) 
                    //...
                

                這樣做的缺點是代碼的目的不是很明確.此外,即使找到了元素,它也不會停止遍歷數組,盡管這更像是一個挑剔(如果數據集大到足以引起問題,則無論如何線性搜索都不是答案)

                The downside of this is that the code's purpose is not immediately clear. Also, it won't stop iterating over the array even if the element was found, although this is more of a nitpick (if the data set is large enough to cause problems, linear search won't be an answer anyway)

                推薦答案

                您可以編寫自己的函數 ;)

                You can write your own function ;)

                function callback_search ($array, $callback) { // name may vary
                    return array_filter($array, $callback);
                }
                

                這可能看起來沒用,但它增加了語義并可以增加可讀性

                This maybe seems useless, but it increases semantics and can increase readability

                這篇關于使用用戶定義函數搜索 PHP 數組的優雅方式的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                相關文檔推薦

                Deadlock exception code for PHP, MySQL PDOException?(PHP、MySQL PDOException 的死鎖異常代碼?)
                PHP PDO MySQL scrollable cursor doesn#39;t work(PHP PDO MySQL 可滾動游標不起作用)
                PHP PDO ODBC connection(PHP PDO ODBC 連接)
                Using PDO::FETCH_CLASS with Magic Methods(使用 PDO::FETCH_CLASS 和魔術方法)
                php pdo get only one value from mysql; value that equals to variable(php pdo 只從 mysql 獲取一個值;等于變量的值)
                MSSQL PDO could not find driver(MSSQL PDO 找不到驅動程序)
                <i id='80MsU'><tr id='80MsU'><dt id='80MsU'><q id='80MsU'><span id='80MsU'><b id='80MsU'><form id='80MsU'><ins id='80MsU'></ins><ul id='80MsU'></ul><sub id='80MsU'></sub></form><legend id='80MsU'></legend><bdo id='80MsU'><pre id='80MsU'><center id='80MsU'></center></pre></bdo></b><th id='80MsU'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='80MsU'><tfoot id='80MsU'></tfoot><dl id='80MsU'><fieldset id='80MsU'></fieldset></dl></div>

                  <bdo id='80MsU'></bdo><ul id='80MsU'></ul>

                  <small id='80MsU'></small><noframes id='80MsU'>

                      <legend id='80MsU'><style id='80MsU'><dir id='80MsU'><q id='80MsU'></q></dir></style></legend>
                        • <tfoot id='80MsU'></tfoot>
                            <tbody id='80MsU'></tbody>
                        • 主站蜘蛛池模板: 国产精久久久久久久妇剪断 | 成人av播放 | 国产网站久久 | 欧美a√| 欧美 日韩 在线播放 | 亚州中文字幕 | 一区二区三区在线播放 | www.蜜桃av | 国产免费观看一级国产 | 一级做a| www.亚洲免费| 久久久久久天堂 | 日韩高清成人 | 日韩综合网 | 久久精品国产一区二区三区不卡 | 国产激情免费视频 | 亚洲一区二区视频在线观看 | 亚洲欧美在线一区 | a亚洲精品 | 蜜桃黄网 | 在线色网 | h视频免费在线观看 | 狠狠操狠狠干 | 91精品国产综合久久婷婷香蕉 | 精品二| 一区二区av| 日韩2020狼一二三 | 一区二区三区av | 中文在线一区二区 | 欧美一级免费 | 国产人成精品一区二区三 | 亚洲精彩视频在线观看 | 精品国产一区二区三区久久久四川 | 亚洲成人一区二区三区 | 国内精品久久影院 | h在线观看 | 91久久国产综合久久 | 国产亚洲精品精品国产亚洲综合 | 一区视频在线 | 日本三级电影在线观看视频 | 日韩欧美在线观看视频 |