<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>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                # 數組輔助函數 數組輔助函數文件包含了一些幫助你處理數組的函數。 [TOC=2,3] ## 加載輔助函數 該輔助函數通過下面的代碼加載: ~~~ $this->load->helper('array'); ~~~ ## 可用函數 該輔助函數有下列可用函數: element($item,?$array[,?$default = NULL]) 參數: * **$item**?(string) -- Item to fetch from the array * **$array**?(array) -- Input array * **$default**?(bool) -- What to return if the array isn't valid 返回: NULL on failure or the array item. 返回類型: mixed 該函數通過索引獲取數組中的元素。它會測試索引是否設置并且有值,如果有值, 函數將返回該值,如果沒有值,默認返回 NULL 或返回通過第三個參數設置的默認值。 示例: ~~~ $array = array( 'color' => 'red', 'shape' => 'round', 'size' => '' ); echo element('color', $array); // returns "red" echo element('size', $array, 'foobar'); // returns "foobar" ~~~ elements($items,?$array[,?$default = NULL]) 參數: * **$item**?(string) -- Item to fetch from the array * **$array**?(array) -- Input array * **$default**?(bool) -- What to return if the array isn't valid 返回: NULL on failure or the array item. 返回類型: mixed 該函數通過多個索引獲取數組中的多個元素。它會測試每一個索引是否設置并且有值, 如果其中某個索引沒有值,返回結果中該索引所對應的元素將被置為 NULL ,或者 通過第三個參數設置的默認值。 示例: ~~~ $array = array( 'color' => 'red', 'shape' => 'round', 'radius' => '10', 'diameter' => '20' ); $my_shape = elements(array('color', 'shape', 'height'), $array); ~~~ 上面的函數返回的結果如下: ~~~ array( 'color' => 'red', 'shape' => 'round', 'height' => NULL ); ~~~ 你可以通過第三個參數設置任何你想要設置的默認值。 ~~~ $my_shape = elements(array('color', 'shape', 'height'), $array, 'foobar'); ~~~ 上面的函數返回的結果如下: ~~~ array( 'color' => 'red', 'shape' => 'round', 'height' => 'foobar' ); ~~~ 當你需要將?$_POST?數組傳遞到你的模型中時這將很有用,這可以防止用戶發送額外的數據 被寫入到你的數據庫。 ~~~ $this->load->model('post_model'); $this->post_model->update( elements(array('id', 'title', 'content'), $_POST) ); ~~~ 從上例中可以看出,只有 id、title、content 三個字段被更新。 random_element($array) 參數: * **$array**?(array) -- Input array 返回: A random element from the array 返回類型: mixed 傳入一個數組,并返回數組中隨機的一個元素。 使用示例: ~~~ $quotes = array( "I find that the harder I work, the more luck I seem to have. - Thomas Jefferson", "Don't stay in bed, unless you can make money in bed. - George Burns", "We didn't lose the game; we just ran out of time. - Vince Lombardi", "If everything seems under control, you're not going fast enough. - Mario Andretti", "Reality is merely an illusion, albeit a very persistent one. - Albert Einstein", "Chance favors the prepared mind - Louis Pasteur" ); echo random_element($quotes); ~~~
                  <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>

                              哎呀哎呀视频在线观看