<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                # 數組助手函數 ### [](https://octobercms.com/docs/services/helpers#arrays)數組 #### [](https://octobercms.com/docs/services/helpers#method-array-add)`array_add()` 如果`array_add`給定鍵/值對在數組中不存在,則該函數將其添加到數組: ~~~ $array = array_add(['name' => 'Desk'], 'price', 100); // ['name' => 'Desk', 'price' => 100] ~~~ #### [](https://octobercms.com/docs/services/helpers#method-array-divide)`array_divide()` 該`array_divide`函數返回兩個數組,一個包含鍵,另一個包含原始數組的值: ~~~ list($keys, $values) = array_divide(['name' => 'Desk']); // $keys: ['name'] // $values: ['Desk'] ~~~ #### [](https://octobercms.com/docs/services/helpers#method-array-dot)`array_dot()` 該`array_dot`函數將多維數組展平為使用“點”符號表示深度的單級數組: ~~~ $array = array_dot(['foo' => ['bar' => 'baz']]); // ['foo.bar' => 'baz']; ~~~ #### [](https://octobercms.com/docs/services/helpers#method-array-undot)`array_undot()` 該`array_undot`功能是該`array_dot`方法的對立部分。它將點標記的數組轉換為標準的關聯數組: ~~~ $array = array_undot([ 'foo.bar' => 'baz' ]); // [ // 'foo' => [ // 'bar' => 'baz' // ] // ] ~~~ #### [](https://octobercms.com/docs/services/helpers#method-array-except)`array_except()` 該`array_except`方法從數組中刪除給定的鍵/值對: ~~~ $array = ['name' => 'Desk', 'price' => 100]; $array = array_except($array, ['price']); // ['name' => 'Desk'] ~~~ #### [](https://octobercms.com/docs/services/helpers#method-array-first)`array_first()` 該`array_first`方法返回通過給定真值測試的數組的第一個元素: ~~~ $array = [100, 200, 300]; $value = array_first($array, function ($key, $value) { return $value >= 150; }); // 200 ~~~ 還可以將默認值作為第三個參數傳遞給該方法。如果沒有任何值通過真實性測試,則將返回此值: ~~~ $value = array_first($array, $callback, $default); ~~~ #### [](https://octobercms.com/docs/services/helpers#method-array-flatten)`array_flatten()` 該`array_flatten`方法將把多維數組展平為單個級別。 ~~~ $array = ['name' => 'Joe', 'languages' => ['PHP', 'Ruby']]; $array = array_flatten($array); // ['Joe', 'PHP', 'Ruby']; ~~~ #### [](https://octobercms.com/docs/services/helpers#method-array-forget)`array_forget()` 該`array_forget`方法使用“點”符號從深度嵌套的數組中刪除給定的鍵/值對: ~~~ $array = ['products' => ['desk' => ['price' => 100]]]; array_forget($array, 'products.desk'); // ['products' => []] ~~~ #### [](https://octobercms.com/docs/services/helpers#method-array-get)`array_get()` 該`array_get`方法使用“點”表示法從深度嵌套的數組中檢索值: ~~~ $array = ['products' => ['desk' => ['price' => 100]]]; $value = array_get($array, 'products.desk'); // ['price' => 100] ~~~ 該`array_get`函數還接受默認值,如果未找到特定鍵,則將返回該默認值: ~~~ $value = array_get($array, 'names.john', 'default'); ~~~ #### [](https://octobercms.com/docs/services/helpers#method-array-only)`array_only()` 該`array_only`方法將只返回給定數組中的指定鍵/值對: ~~~ $array = ['name' => 'Desk', 'price' => 100, 'orders' => 10]; $array = array_only($array, ['name', 'price']); // ['name' => 'Desk', 'price' => 100] ~~~ #### [](https://octobercms.com/docs/services/helpers#method-array-pluck)`array_pluck()` 該`array_pluck`方法將從數組中提取給定鍵/值對的列表: ~~~ $array = [ ['developer' => ['name' => 'Brian']], ['developer' => ['name' => 'Stewie']] ]; $array = array_pluck($array, 'developer.name'); // ['Brian', 'Stewie']; ~~~ #### [](https://octobercms.com/docs/services/helpers#method-array-pull)`array_pull()` 該`array_pull`方法返回并從數組中刪除鍵/值對: ~~~ $array = ['name' => 'Desk', 'price' => 100]; $name = array_pull($array, 'name'); // $name: Desk // $array: ['price' => 100] ~~~ #### [](https://octobercms.com/docs/services/helpers#method-array-set)`array_set()` 該`array_set`方法使用“點”符號在深層嵌套的數組中設置一個值: ~~~ $array = ['products' => ['desk' => ['price' => 100]]]; array_set($array, 'products.desk.price', 200); // ['products' => ['desk' => ['price' => 200]]] ~~~ #### [](https://octobercms.com/docs/services/helpers#method-array-sort)`array_sort()` 該`array_sort`方法根據給定Closure的結果對數組進行排序: ~~~ $array = [ ['name' => 'Desk'], ['name' => 'Chair'], ]; $array = array_values(array_sort($array, function ($value) { return $value['name']; })); /* [ ['name' => 'Chair'], ['name' => 'Desk'], ] */ ~~~ #### [](https://octobercms.com/docs/services/helpers#method-array-sort-recursive)`array_sort_recursive()` 該`array_sort_recursive`函數使用以下`sort`函數對數組進行遞歸排序: ~~~ $array = [ [ 'Brian', 'Shannon', 'Alec', ], [ 'PHP', 'Ruby', 'JavaScript', ], ]; $array = array_sort_recursive($array); /* [ [ 'Alec', 'Brian', 'Shannon', ], [ 'JavaScript', 'PHP', 'Ruby', ] ]; */ ~~~ #### [](https://octobercms.com/docs/services/helpers#method-array-where)`array_where()` 該`array_where`函數使用給定的Closure過濾數組: ~~~ $array = [100, '200', 300, '400', 500]; $array = array_where($array, function ($value, $key) { return is_string($value); }); // [1 => 200, 3 => 400] ~~~ #### [](https://octobercms.com/docs/services/helpers#method-head)`head()` 該`head`函數僅返回給定數組中的第一個元素: ~~~ $array = [100, 200, 300]; $first = head($array); // 100 ~~~ #### [](https://octobercms.com/docs/services/helpers#method-last)`last()` 該`last`函數返回給定數組中的最后一個元素: ~~~ $array = [100, 200, 300]; $last = last($array); // 300 ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看