久久久久久久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>
                        • 主站蜘蛛池模板: 韩日一区二区 | 亚洲国产高清高潮精品美女 | 亚洲 欧美 日韩 在线 | 啪啪综合网 | 日韩视频在线一区 | 一区二区免费在线观看 | 亚洲精品在线91 | 爱爱视频在线观看 | 秋霞电影院午夜伦 | 亚洲精品久久久一区二区三区 | av成年人网站 | 久色激情| 日韩成人 | 欧美精品一区二区三区四区 在线 | 我我色综合 | 性一爱一乱一交一视频 | 精品日韩一区二区三区av动图 | 日韩国产欧美一区 | www.狠狠干 | 久久久久久高潮国产精品视 | 亚洲精品成人在线 | 亚洲国产一区在线 | 一级黄色毛片 | av黄色在线| 国产精品久久久爽爽爽麻豆色哟哟 | 日韩一区二区三区av | 人人澡人人爱 | 麻豆精品一区二区三区在线观看 | 久草在线青青草 | 亚洲毛片 | 中文字幕av亚洲精品一部二部 | 国产精品成人在线 | 国产精品av久久久久久毛片 | 一级毛片视频在线 | 91av在线影院| 免费能直接在线观看黄的视频 | 国产伦精品一区二区三区视频金莲 | 国产精品一区二区久久精品爱微奶 | 国产精品久久久久久久久久免费看 | 国产精品久久7777777 | 91欧美激情一区二区三区成人 |