当前位置:网站首页>PHP 零基础入门笔记(13):数组相关函数
PHP 零基础入门笔记(13):数组相关函数
2022-04-23 16:08:00 【彭世瑜psy】
数组相关函数
自定义数组打印函数,便于查看
排序函数
按照 ASCII 码排序
sort 对 array 本身按照值(value)升序排序。(下标重排)
rsort 对 array 本身按照值(value)降序排序。
asort 对 array 自身按照升序进行排序(下标保留)
arsort 对 array 本身按照降序排序
ksort 对 array 本身进行按键(key)升序排序。
krsort 对 array 本身按照键(key)降序排序。
shuffle 随机打乱
指针函数
reset 将 array 的内部指针倒回到第一个单元并返回第一个数组单元的值。
end 将 array 的内部指针移动到最后一个单元并返回其值。
next 将数组中的内部指针向前移动一位
prev 将数组的内部指针倒回一位
current 返回数组中的当前值
key 返回数组中当前单元的键名。
注意:next 和 prev 移动指针,可能移出数组,只能通过 end 或者 reset 重置指针
示例
其他函数
count 统计数组、Countable 对象中所有元素的数量
array_push 将 array 当成一个栈,并将传入的变量压入 array 的末尾。
array_pop 弹出并返回 array 最后一个元素的值
array_shift 将 array 的第一个单元移出并作为结果返回
array_unshift 在数组开头插入一个或多个单元
数据结构
- 栈 压栈,FILO先进后出
- 队列 排队,FIFO 先进先出
实现栈:
- 前面 array_unshift/array_shift
- 后面 array_push/array_pop
实现队列:
- 后进前出 array_push/array_shift
- 前进后出 array_unshift/array_pop
array_reverse 返回一个单元为相反顺序的新数组
in_array 检查数组中是否存在某个值
array_keys 返回数组中部分的或所有的键名
array_values 返回 input 数组中所有的值并给其建立数字索引。
版权声明
本文为[彭世瑜psy]所创,转载请带上原文链接,感谢
https://blog.51cto.com/u_13567403/5248596
边栏推荐
- JSP learning 3
- Nanny Anaconda installation tutorial
- Fastjon2 here he is, the performance is significantly improved, and he can fight for another ten years
- RecyclerView advanced use - to realize drag and drop function of imitation Alipay menu edit page
- Countdown 1 day ~ 2022 online conference of cloud disaster tolerance products is about to begin
- gps北斗高精度卫星时间同步系统应用案例
- VIM uses vundle to install the code completion plug-in (youcompleteme)
- 299. Number guessing game
- GRBL学习(二)
- Spark 算子之distinct使用
猜你喜欢

撿起MATLAB的第(9)天

Spark 算子之coalesce与repartition

How to upgrade openstack across versions

【现代电子装联期末复习要点】

下载并安装MongoDB

Hypermotion cloud migration helped China Unicom. Qingyun completed the cloud project of a central enterprise and accelerated the cloud process of the group's core business system

Gartner predicts that the scale of cloud migration will increase significantly; What are the advantages of cloud migration?

Function summary of drawing object arrangement in R language

MetaLife与ESTV建立战略合作伙伴关系并任命其首席执行官Eric Yoon为顾问

Download and install mongodb
随机推荐
Start Oracle service on Linux
捡起MATLAB的第(6)天
Win11/10家庭版禁用Edge的inprivate浏览功能
Day (7) of picking up matlab
捡起MATLAB的第(5)天
Hyperbdr cloud disaster recovery v3 Release of version 3.0 | upgrade of disaster recovery function and optimization of resource group management function
Partitionby of spark operator
Ice -- source code analysis
Algorithem_ ReverseLinkedList
MetaLife与ESTV建立战略合作伙伴关系并任命其首席执行官Eric Yoon为顾问
Hyperbdr cloud disaster recovery v3 Version 2.1 release supports more cloud platforms and adds monitoring and alarm functions
Function summary of drawing object arrangement in R language
Spark 算子之coalesce与repartition
Spark 算子之交集、并集、差集
How to conduct application security test (AST)
C#,贝尔数(Bell Number)的计算方法与源程序
捡起MATLAB的第(4)天
MySQL - MySQL查询语句的执行过程
The system research problem that has plagued for many years has automatic collection tools, which are open source and free
最详细的背包问题!!!