array_keys_PHP array_keys()函数与示例
array_keys
PHP array_keys()函数 (PHP array_keys() function)
array_keys() function is used to get the keys of an array, it accepts an array as an argument and returns a new array containing keys.
array_keys()函数用于获取数组的键,它接受一个数组作为参数并返回一个包含键的新数组。
Syntax:
句法:
array_keys(input_array, [value], [strict]);
Here,
这里,
input_array is an array (i.e. input array).
input_array是一个数组(即输入数组)。
value is an optional parameter, it is used to define a value if the value is defined, then the only keys having that value are returned.
value是一个可选参数,如果定义了值,则用于定义值,然后仅返回具有该值的键。
strict is also an optional parameter, it is default set to false if we set it true the type of values will be checked.
严格也是一个可选的参数,它是默认设置为false,如果我们把它真值的类型将被检查。
Examples:
例子:
Input:
$per = array("name" => "Amit", "age" => 21, "gender" => "Male");
Output:
Array
(
[0] => name
[1] => age
[2] => gender
)
PHP code 1: array with and without containing keys
PHP代码1:包含和不包含键的数组
<?php
$per = array("name" => "Amit", "age" => 21, "gender" => "Male");
print ("keys array...\n");
print_r (array_keys($per));
//array with out keys
$arr = array("Hello", "world", 100, 200, -10);
print ("keys array...\n");
print_r (array_keys($arr));
?>
Output
输出量
keys array...
Array
(
[0] => name
[1] => age
[2] => gender
)
keys array...
Array
(
[0] => 0
[1] => 1
[2] => 2
[3] => 3
[4] => 4
)
PHP code 2: Using value and strict mode
PHP代码2:使用值和严格模式
<?php
$arr = array("101" => 100, "102" => "100", "103" => 200);
print("output (default function call)...\n");
print_r (array_keys($arr));
print("output (with checking value)...\n");
print_r (array_keys($arr, 100));
print("output (with checking value & strict mode)...\n");
print_r (array_keys($arr, 100, true));
?>
Output
输出量
output (default function call)...
Array
(
[0] => 101
[1] => 102
[2] => 103
)
output (with checking value)...
Array
(
[0] => 101
[1] => 102
)
output (with checking value & strict mode)...
Array
(
[0] => 101
)
翻译自: https://www.includehelp.com/php/array_keys-function-with-example.aspx
array_keys
array_keys_PHP array_keys()函数与示例相关推荐
- php指定长度 分割整形,php指定长度分割字符串str_split函数用法示例
本文实例讲述了php指定长度分割字符串str_split函数用法.分享给大家供大家参考,具体如下: 示例1:$str = 'abcdefgh'; $arr = str_split($str,2); 运 ...
- getdate函数_PHP getdate()函数与示例
getdate函数 PHP getdate()函数 (PHP getdate() function) getdate() function is used to get the local date/ ...
- 安卓log.e函数打印示例_log1p()函数以及C ++中的示例
安卓log.e函数打印示例 C ++ log1p()函数 (C++ log1p() function) log1p() function is a library function of cmath ...
- gettimeofday_PHP gettimeofday()函数与示例
gettimeofday PHP gettimeofday()函数 (PHP gettimeofday() function) gettimeofday() function is used to g ...
- dir函数_PHP dir()函数与示例
dir函数 PHP dir()函数 (PHP dir() function) dir() function is an instance of the directory class, it is u ...
- PHP rewinddir()函数与示例
PHP rewinddir()函数 (PHP rewinddir() function) rewinddir() function is used to rewind/reset the direct ...
- stl swap函数_C ++ STL | vector :: swap()函数与示例
stl swap函数 C ++ STL vector :: swap()函数 (C++ STL vector::swap() function) vector::swap() function is ...
- C#回调函数应用示例,形象比喻方法助理解
C#回调函数应用示例,形象比喻方法助理解,整理了一个简单的例子来说明回调函数的用法: namespace CallBackFunction { class Program { ...
- php解escape,PHP下escape解码函数用法示例
这篇文章主要为大家详细介绍了PHP下escape解码函数用法示例,具有一定的参考价值,可以用来参考一下. 感兴趣的小伙伴,下面一起跟随512笔记的小编小韵来看看吧!GB2312编码: 代码如下: fu ...
最新文章
- 科技部向全社会征集颠覆性技术研发方向
- Mybatis 强大的结果映射器ResultMap
- 漫长的数据中心绿化之路到底该如何走www.shzhenai.com
- java对象的内存结构_JAVA 对象内存结构
- 不同类别的图像数量可视化
- 微信“支付”页新增“出行服务” :已上线北深广三城
- 题目1057:众数----------------------位置,位置-------------如何控制while的循环条件,先输入一个数,再在while里面输入其他的19个数...
- html5技术英文论文参考文献,英文论文的参考文献范例(精选8篇)
- python 菜品识别_利用百度智能云结合Python体验图像识别(来自qylruirui)
- Python获取日期列表中每一天中最大的时刻对应的日期时间戳
- s3c2440的pwm输出
- FreeFileSync 文件夹比较与同步软件
- FSCapture录屏软件
- 关于3CDaemon的FTP服务端异常
- 计算机便签中字的大小,Windows便签字体怎么调整?电脑便签怎么改字体大小
- 关于闰年和平年的每个月有多少天
- [4G/5G/6G专题基础-157]: 无线数据承载DRB与无线信令承载SRB
- 原笔迹手写实现平滑和笔锋效果之:笔锋效果(三)[完结篇]
- 西南交大计算机应用基础离线作业答案,西南交大计算机应用基础1-5作业答案.doc...
- Address Sanitizer(Asan)原理及相关GCC选项列表
热门文章
- 新手攻略熔炉_我的世界攻略:生存模式新手攻略
- Pycharm远程连接服务器,操作代码
- 认识VLAN,并学会VLAN的划分和网络配置实例
- Angular实现图片点击缩放组件
- 左偏树 P3377【模板】左偏树(可并堆)
- 类似索引Model套Model之 iOS模型闲聊二
- 委托BegionInvoke和窗体BegionInvoke
- Python基础--环境配置、编码风格、基础概念、基本数据类型(1)
- js中加“var”和不加“var”的区别,看完觉得这么多年js白学了
- iOS中的UIScrollView(滑动视图)