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

directory search
Array Array Helper Benchmarking Benchmarking Class Caching Caching Driver Calendaring Calendaring Class CAPTCHA CAPTCHA Helper Config Config Class Cookie Cookie Helper Database Connecting to your Database Custom Function Calls Database Caching Class Database Configuration Database Forge Class Database Metadata Database Quick Start: Example Code Database Reference Database Utility Class DB Driver Reference Generating Query Results Queries Query Builder Class Query Helper Methods Transactions Date Date Helper Directory Directory Helper Download Download Helper Email Email Class Email Helper Encrypt Encrypt Class Encryption Encryption Library File File Helper File Uploading File Uploading Class Form Form Helper Form Validation Form Validation FTP FTP Class Functions compatibility_functions common_functions HTML HTML Helper HTML Table HTML Table Class Image Manipulation Image Manipulation Class Inflector Inflector Helper Input Input Class Javascript Javascript Class Language Language Class Language Helper Loader Loader Class Migrations Migrations Class Number Number Helper Output Output Class Pagination Pagination Class Path Path Helper Security Security Class Security Helper Session Session Library Shopping Cart Shopping Cart Class Smiley Smiley Helper String String Helper Template Parser Template Parser Class Text Text Helper Trackback Trackback Class Typography Typography Class Typography Helper Unit Testing Unit Testing Class URI URL User Agent XML XML-RPC and XML-RPC Server Zip Encoding Zip Encoding Class XML-RPC and XML-RPC Server Classes XML Helper User Agent Class URL Helper URI Class
characters

Array Helper文件包含有助于處理數(shù)組的函數(shù)。

  • 加載此助手

  • 可用職能

加載此助手

使用以下代碼加載此助手:

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

可用職能

現(xiàn)有下列職能:

element($item, $array[, $default = NULL])

參數(shù):

$ item(string) - 從數(shù)組中獲取的項(xiàng)目$ array(array) - 輸入數(shù)組$ default(bool) - 如果數(shù)組無效

返回:

NULL失敗或數(shù)組項(xiàng)。

返回類型:

  • $item (string) -從數(shù)組中獲取的項(xiàng)

  • $array (array) -輸入數(shù)組

  • $ defaultbool) - 如果數(shù)組無效應(yīng)該返回什么。

返回:失敗或數(shù)組項(xiàng)時(shí)返回NULL。
返回類型:混合
讓您從數(shù)組中獲取項(xiàng)目。該函數(shù)測試數(shù)組索引是否已設(shè)置以及是否有值。如果存在值,則返回該值。如果值不存在,則返回NULL,或者通過第三個(gè)參數(shù)指定為默認(rèn)值。

例子:

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

 echo元素('color',$ array); //返回“紅色”

echo元素('size',$ array,'foobar'); //返回“foobar”

elements($items, $array[, $default = NULL])

參數(shù):

$ item(string) - 從數(shù)組中獲取的項(xiàng)目$ array(array) - 輸入數(shù)組$ default(bool) - 如果數(shù)組無效

返回:

NULL失敗或數(shù)組項(xiàng)。

返回類型:

  • $ itemstring) - 從數(shù)組中獲取的項(xiàng)目

  • $ arrayarray) - 輸入數(shù)組

  • $ defaultbool) - 如果數(shù)組無效那么返回什么

返回:失敗或數(shù)組項(xiàng)時(shí)返回NULL。
返回類型:混合
讓您從數(shù)組中獲取多個(gè)項(xiàng)目。該函數(shù)測試是否設(shè)置每個(gè)數(shù)組索引。如果索引不存在,它將被設(shè)置為NULL,或者通過第三個(gè)參數(shù)指定為默認(rèn)值。

例子:

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

以上將返回以下數(shù)組:

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

您可以將第三個(gè)參數(shù)設(shè)置為您喜歡的任何默認(rèn)值。

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

以上將返回以下數(shù)組:

數(shù)組('color'=>'red','shape'=>'round','height'=>'foobar');

$_POST數(shù)組發(fā)送到其中一個(gè)模型時(shí)非常有用。這可以防止用戶發(fā)送額外的POST數(shù)據(jù)輸入到表中。

$this - >負(fù)載>模型( 'post_model'); $ this-> post_model-> update(elements(array('id','title','content'),$ _POST));

這確保只有id,標(biāo)題和內(nèi)容字段被發(fā)送來更新。

random_element($array)

參數(shù):

$ array(array) - 輸入數(shù)組

返回:

數(shù)組中的隨機(jī)元素

返回類型:

  • $ arrayarray) - 輸入數(shù)組

返回:數(shù)組中的一個(gè)隨機(jī)元素
返回類型:混合
將數(shù)組作為輸入并從中返回一個(gè)隨機(jī)元素。

用法示例:

$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);
Previous article: Next article: