php 数组函数总结
PHP有74个和数组处理相关的函数,这里对php的数组函数做一个总结,做温故而知新之用。
array_change_key_case — 转变数组中所有键值的大小写形式
array_chunk — 将一个数组拆成多个小单元array_combine — 用一个数组的值作为其键名,另一个数组的值作为其值的方法来创建数组
array_count_values — 统计数组中的值出现的次数
array_diff_assoc — 根据值和键值计算若干个数组相对于第一个数组参数的差集
array_diff_key — 根据键值计算若干个数组相对于第一个数组参数的差集
array_diff_uassoc –根据值和键值计算若干个数组相对于第一个数组参数的差集,可使用回调函数对键值进行比较
array_diff_ukey — 根据键值计算若干个数组相对于第一个数组参数的差集,可使用回调函数比较键名
array_diff — 根据值来计算若干个数组相对于第一个数组参数的差集
array_fill — 用给定的值填充数组
array_filter — 使用回调函数对数组进行过滤操作
array_flip — 交换数组中的键和值
array_intersect_assoc — 根据值和键值来计算数组的交集
array_intersect_key — 根据键值比较计算数组的交集
array_intersect_uassoc — 根据值和键值来计算数组的交集,可使用回调函数对键值进行比较
array_intersect_ukey — 根据键值比较计算数组的交集,可使用回调函数比较键名
array_intersect — 根据值来计算数组的交集
array_key_exists — 检查给定的键名是否存在于数组中
array_keys — 返回数组中所有的键名
array_map — 对数组中的每个元素应用回调函数后返回结果
array_merge_recursive — 用来处理多维数组的合并
array_merge — 重排单个数组的键值或者合并两个数组
array_multisort — 对多个数组进行排序,或者对多维数组进行排序
array_pad — 用值将数组填补到指定长度
array_pop — 将数组的最后一个单元弹出
array_product — 得出数组所有单元值的乘积
array_push — 将一个或多个单元添加到数组的末尾
array_rand — 从数组中随机取出一个或多个单元的键名
array_reduce — 对数组中的每个元素应用一个回调函数
array_reverse — 返回一个和原来数组相反的数组
array_search — 在数组中搜索给定的值,如果成功则返回相应的键名
array_shift — 将数组的第一个单元移出并作为结果返回
array_slice — 截取出数组中的一段
array_splice — 将一个数组中的部分截取并替换
array_sum — 得出数组所有值的和
array_udiff_assoc — 根据值和键值来计算数组的交集,可使用回调函数比较值
array_udiff_uassoc — 根据值和键值来计算数组的交集,可使用回调函数比较值
array_udiff — 根据值来计算若干个数组相对于第一个数组参数的差集,可使用回调函数比较值
array_uintersect_assoc — 根据值和键值来计算数组的交集,可使用回调函数对值进行比较
array_uintersect_uassoc — 根据值和键值来计算数组的交集,可使用回调函数对值和键值进行比较
array_uintersect — 根据值来计算数组的交集,可使用回调函数比较值
array_unique — 移除数组中重复的值
array_unshift — 将传入的单元插入到数组的开头
array_values — 返回数组中所有的值
array_walk_recursive — 对数组中的每个元素递归的应用一个回调函数
array_walk — 对数组中的每个元素应用一个回调函数
array — 新建一个数组
arsort — 对数组进行反向,保留键值的排序
asort — 对数组进行保留键值的排序
compact — 将变量转变为数组
count — 计算数组的个数
current — 返回数组的当前单元
each — 返回数组当前指针所在单元的键值和值,并将指针指向下一个单元
end — 将指针指向数组的最后一个单元
extract — 将一个数组的键值作为变量名,将数组的值作为变量的值进行批量赋值
in_array — 检查数组中是否存在某个值
key — 返回当前指针所在数组单元的键名
krsort — 将数组按键名进行反向排序
ksort — 将数组按键名进行排序
list — 将数组的值赋给一些变量
natcasesort — 使用“自然排序”法对数组排序,比较时不区分大小写
natsort — 使用“自然排序”法对数组排序
next — 将指针指向数组的下一个单元
pos — 返回数组的当前单元,是current() 的别称
prev — 将指针指向数组的上一个单元
range — 建立一个包含指定范围单元的数组
reset — 将指针指向数组的第一个单元
rsort — 对数组进行反向排序
shuffle — 将数组打乱,并重建键名
sizeof — 计算数组的个数,作用和count()函数完全相同
sort — 对数组进行排序
uasort — 使用回调函数对数组进行保留键值的排序
uksort — 使用回调函数对数组按键名进行排序
usort — 使用回调函数对数组进行排序

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to optimize the lazy loading effect of images through PHP functions? With the development of the Internet, the number of images in web pages is increasing, which puts pressure on page loading speed. In order to improve user experience and reduce loading time, we can use image lazy loading technology. Lazy loading of images can delay the loading of images. Images are only loaded when the user scrolls to the visible area, which can reduce the loading time of the page and improve the user experience. When writing PHP web pages, we can optimize the lazy loading effect of images by writing some functions. Details below

How to reduce memory usage through PHP functions. In development, memory usage is a very important consideration. If a large amount of memory is used in a program, it may cause slowdowns or even program crashes. Therefore, reasonably managing and reducing memory usage is an issue that every PHP developer should pay attention to. This article will introduce some methods to reduce memory usage through PHP functions, and provide specific code examples for readers' reference. Use the unset() function to release variables in PHP. When a variable is no longer needed, use

PHPDeprecated: Functionereg_replace()isdeprecated-Solution When developing in PHP, we often encounter the problem of some functions being declared deprecated. This means that in the latest PHP versions, these functions may be removed or replaced. One common example is the ereg_replace() function. ereg_replace

The main differences between PHP and Flutter functions are declaration, syntax and return type. PHP functions use implicit return type conversion, while Flutter functions explicitly specify return types; PHP functions can specify optional parameters through ?, while Flutter functions use required and [] to specify required and optional parameters; PHP functions use = to pass naming Parameters, while Flutter functions use {} to specify named parameters.

PHP function introduction: strtr() function In PHP programming, the strtr() function is a very useful string replacement function. It is used to replace specified characters or strings in a string with other characters or strings. This article will introduce the usage of strtr() function and give some specific code examples. The basic syntax of the strtr() function is as follows: strtr(string$str, array$replace) where $str is the original word to be replaced.

PHP image processing functions are a set of functions specifically used to process and edit images. They provide developers with rich image processing functions. Through these functions, developers can implement operations such as cropping, scaling, rotating, and adding watermarks to images to meet different image processing needs. First, I will introduce how to use PHP image processing functions to achieve image cropping function. PHP provides the imagecrop() function, which can be used to crop images. By passing the coordinates and size of the cropping area, we can crop the image

The performance of different PHP functions is crucial to application efficiency. Functions with better performance include echo and print, while functions such as str_replace, array_merge, and file_get_contents have slower performance. For example, the str_replace function is used to replace strings and has moderate performance, while the sprintf function is used to format strings. Performance analysis shows that it only takes 0.05 milliseconds to execute one example, proving that the function performs well. Therefore, using functions wisely can lead to faster and more efficient applications.

PHP functions have similarities with functions in other languages, but also have some unique features. Syntactically, PHP functions are declared with function, JavaScript is declared with function, and Python is declared with def. In terms of parameters and return values, PHP functions accept parameters and return a value. JavaScript and Python also have similar functions, but the syntax is different. In terms of scope, functions in PHP, JavaScript and Python all have global or local scope. Global functions can be accessed from anywhere, and local functions can only be accessed within their declaration scope.
