亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

direktori cari
歡迎 目錄 快速參考圖 基本信息 服務(wù)器要求 許可協(xié)議 變更記錄 關(guān)于CodeIgniter 安裝 下載 CodeIgniter 安裝指導(dǎo) 從老版本升級(jí) 疑難解答 介紹 開(kāi)始 CodeIgniter 是什么? CodeIgniter 速記表 支持特性 應(yīng)用程序流程圖 模型-視圖-控制器 架構(gòu)目標(biāo) 教程 內(nèi)容提要 加載靜態(tài)內(nèi)容 創(chuàng)建新聞條目 讀取新聞條目 結(jié)束語(yǔ) 常規(guī)主題 CodeIgniter URL 控制器 保留字 視圖 模型 輔助函數(shù) 使用 CodeIgniter 類(lèi)庫(kù) 創(chuàng)建你自己的類(lèi)庫(kù) 使用 CodeIgniter 適配器 創(chuàng)建適配器 創(chuàng)建核心系統(tǒng)類(lèi) 鉤子 - 擴(kuò)展框架的核心 自動(dòng)裝載資源 公共函數(shù) URI 路由 錯(cuò)誤處理 緩存 調(diào)試應(yīng)用程序 以CLI方式運(yùn)行 管理應(yīng)用程序 處理多環(huán)境 PHP替代語(yǔ)法 安全 開(kāi)發(fā)規(guī)范 類(lèi)庫(kù)參考 基準(zhǔn)測(cè)試類(lèi) 日歷類(lèi) 購(gòu)物車(chē)類(lèi) 配置類(lèi) Email 類(lèi) 加密類(lèi) 文件上傳類(lèi) 表單驗(yàn)證詳解 FTP 類(lèi) 圖像處理類(lèi) 輸入類(lèi) Javascript 類(lèi) 語(yǔ)言類(lèi) 裝載類(lèi) 遷移類(lèi) 輸出類(lèi) 分頁(yè)類(lèi) 模板解析器類(lèi) 安全類(lèi) Session 類(lèi) HTML 表格類(lèi) 引用通告類(lèi) 排版類(lèi) 單元測(cè)試類(lèi) URI 類(lèi) User-Agent 類(lèi) 表單驗(yàn)證 XML-RPC 和 XML-RPC 服務(wù)器 Zip 編碼類(lèi) 緩存適配器 適配器參考 適配器 數(shù)據(jù)庫(kù)類(lèi) Active Record 類(lèi) 數(shù)據(jù)庫(kù)緩存類(lèi) 自定義函數(shù)調(diào)用 數(shù)據(jù)庫(kù)配置 連接你的數(shù)據(jù)庫(kù) 數(shù)據(jù)庫(kù)快速入門(mén)例子代碼 字段數(shù)據(jù) 數(shù)據(jù)庫(kù)維護(hù)類(lèi) 查詢(xún)輔助函數(shù) 數(shù)據(jù)庫(kù)類(lèi) 查詢(xún) 生成查詢(xún)記錄集 表數(shù)據(jù) 事務(wù) 數(shù)據(jù)庫(kù)工具類(lèi) JavaScript類(lèi) 輔助函數(shù)參考 數(shù)組輔助函數(shù) CAPTCHA 輔助函數(shù) Cookie Helper 日期輔助函數(shù) 目錄輔助函數(shù) 下載輔助函數(shù) Email 輔助函數(shù) 文件輔助函數(shù) 表單輔助函數(shù) HTML輔助函數(shù) Inflector 輔助函數(shù) 語(yǔ)言輔助函數(shù) 數(shù)字輔助函數(shù) 路徑輔助函數(shù) 安全輔助函數(shù) 表情輔助函數(shù) 字符串輔助函數(shù) 文本輔助函數(shù) 排版輔助函數(shù) URL 輔助函數(shù) XML 輔助函數(shù)
watak

CodeIgniter 用戶(hù)指南 版本 2.1.0

編輯文檔、查看近期更改請(qǐng) 登錄 或 注冊(cè)  找回密碼
查看原文

數(shù)組輔助函數(shù)

數(shù)組輔助函數(shù)的文件涵蓋了一些用于輔助數(shù)組操作的函數(shù)。

裝載本輔助函數(shù)

本輔助函數(shù)的裝載通過(guò)如下代碼完成:

$this->load->helper('array');

可用的函數(shù)如下:

element()

獲取數(shù)組中的元素。本函數(shù)測(cè)試數(shù)組的索引是否已設(shè)定并含有數(shù)值。如果已設(shè)有數(shù)值則返回該數(shù)值,否則返回 FALSE,或任何你設(shè)定的默認(rèn)數(shù)值(函數(shù)第三個(gè)參數(shù))。范例:

$array = array('color' => 'red', 'shape' => 'round', 'size' => '');

// 返回 "red"
echo element('color', $array);

// 返回 NULL
echo element('size', $array, NULL);

random_element()

根據(jù)提供的數(shù)組,隨機(jī)返回該數(shù)組內(nèi)的一個(gè)元素。使用范例:

$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);

elements()

Lets you fetch a number of items from an array. The function tests whether each of the array indices is set. If an index does not exist it is set to FALSE, or whatever you've specified as the default value via the third parameter. Example:

試譯:該函數(shù)從一個(gè)數(shù)組中取得若干元素。該函數(shù)測(cè)試(傳入)數(shù)組的每個(gè)鍵值是否在(目標(biāo))數(shù)組中已定義;如果一個(gè)鍵值不存在,該鍵值所對(duì)應(yīng)的值將被置為FALSE,或者你可以通過(guò)傳入的第3個(gè)參數(shù)來(lái)指定默認(rèn)的值。例如:

$array = array(
????'color' => 'red',
????'shape' => 'round',
????'radius' => '10',
????'diameter' => '20'
);

$my_shape = elements(array('color', 'shape', 'height'), $array);

The above will return the following array:

試譯:上面的程序?qū)⒎祷叵旅娴臄?shù)組:

array(
????'color' => 'red',
????'shape' => 'round',
????'height' => FALSE
);

You can set the third parameter to any default value you like:

試譯:你可以將第3個(gè)參數(shù)設(shè)為任何你想要的默認(rèn)值:

$my_shape = elements(array('color', 'shape', 'height'), $array, NULL);

The above will return the following array:

試譯:上面的程序?qū)⒎祷叵旅娴臄?shù)組:

array(
????'color' => 'red',
????'shape' => 'round',
????'height' => NULL
);

This is useful when sending the $_POST array to one of your Models. This prevents users from sending additional POST data to be entered into your tables:

試譯:這(種方法)在將 $_POST 數(shù)組傳入你的模型時(shí)非常有用。通過(guò)這種方式可以防止用戶(hù)發(fā)送的額外的 POST 數(shù)據(jù)進(jìn)入你的數(shù)據(jù)表:

$this->load->model('post_model');

$this->post_model->update(elements(array('id', 'title', 'content'), $_POST));

This ensures that only the id, title and content fields are sent to be updated.

試譯:這樣保證了只有 id, title 和 content 字段被發(fā)送以進(jìn)行更新。

?

翻譯貢獻(xiàn)者: canglan, Hex, zhaosusen
最后修改: 2012-02-05 23:45:13
Artikel sebelumnya: Artikel seterusnya: