Home Backend Development PHP Tutorial PHP数组函数 数组中的杂项

PHP数组函数 数组中的杂项

Jun 23, 2016 pm 01:42 PM

array_change_key_case( $arr ,CASE_LOWER || CASE_UPPER) 返回键名全为大写或者是小写的数组

array_rand($arr , num) 从数组中随机取出一个或多个单元

shuffle(&$arr)   将数组打乱

array_chunk($arr , $size , bool) 把$arr 拆分,每个数组为$size 个元素 , bool 是否保持原来索引


array_combine( $arr , $arr2) 合并两个数组  $arr 的键名为键名 $arr2 的键值为键值

array_count_values($arr); 返回一位数组 $arr 的值为键名 在数组中出现的次数为 值

array_slice($arr)  从数组中取出一段


array_fill($start , $Num , $value)  用value 从start 填充num 次

array_pad ( $arr , pad_size , pad_value) 用value 将$arr 补充道长度为size ,size 为正补充道数组后边,否则相反


array_merge($arr , $arr2 ,[……])  合并一个或两个数组 键名相同覆盖

array_merge_recursive($arr , $arr2 [……]) 递归合并一个或多个数组


array_reverse($arr)  返回一个单元顺序相反的数组


array_filter($arr , 'callback'); 用回调函数过滤数组

array_unique($arr);  移除数组中重复的值

array_splice($arr)  把数组中的一部分去掉并用其他值代替



array_flip($arr);  反转数组  ,如果一个值出现多次 最后一个键名将作为他的值

array_key_exists($key , $arr)  给定键名 和索引 是否存在于数组中

in_array( $key , $arr ) 数组中是否存在某个值

array_keys( $arr ) 返回数组中所有的键名

array_search( 'key' ,$arr) 在数组中搜索给定的值 成功返回键名

array_values( $arr ) 返回数组中所有的键值

count($arr ) 数组中的单元数组  或 对象中年个的属性个数

array_sum ( $arr ) 数组中所有值的和

list($arr)  把数组中的值赋给一些变量


array_map('function' , $arr) 将回调函数作用到给定数组的单元上;

array_walk($arr , ’function‘) 对数组中的每个成员应用用户函数

array_walk($arr , 'callback')  对数组中的每个成员递归的应用用户函数



array_reduce($arr , 'callback' , ' initial') 将数组用用户自定义函数 将数组化简为一得值

array_pridect($arr ) 数组中所有值的乘积

compact( 'aa',$arr )  将变量添加到数组当中

extract($arr) 数组将变量 导入到当前符号表



array_pop($arr)  将数组最后一个单元弹出 长度并减一 (出栈)

array_push($arr , mixed)  将一个或多个单元压入数组末尾(入栈)

array_shift(&$arr);  将数组开头的单元移除数组

array_unshift($arr , $mixed); 从数组开头插入一个或多个单元


Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

11 Best PHP URL Shortener Scripts (Free and Premium) 11 Best PHP URL Shortener Scripts (Free and Premium) Mar 03, 2025 am 10:49 AM

11 Best PHP URL Shortener Scripts (Free and Premium)

Introduction to the Instagram API Introduction to the Instagram API Mar 02, 2025 am 09:32 AM

Introduction to the Instagram API

Working with Flash Session Data in Laravel Working with Flash Session Data in Laravel Mar 12, 2025 pm 05:08 PM

Working with Flash Session Data in Laravel

Build a React App With a Laravel Back End: Part 2, React Build a React App With a Laravel Back End: Part 2, React Mar 04, 2025 am 09:33 AM

Build a React App With a Laravel Back End: Part 2, React

Simplified HTTP Response Mocking in Laravel Tests Simplified HTTP Response Mocking in Laravel Tests Mar 12, 2025 pm 05:09 PM

Simplified HTTP Response Mocking in Laravel Tests

cURL in PHP: How to Use the PHP cURL Extension in REST APIs cURL in PHP: How to Use the PHP cURL Extension in REST APIs Mar 14, 2025 am 11:42 AM

cURL in PHP: How to Use the PHP cURL Extension in REST APIs

12 Best PHP Chat Scripts on CodeCanyon 12 Best PHP Chat Scripts on CodeCanyon Mar 13, 2025 pm 12:08 PM

12 Best PHP Chat Scripts on CodeCanyon

Notifications in Laravel Notifications in Laravel Mar 04, 2025 am 09:22 AM

Notifications in Laravel

See all articles