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 ...
最新文章
- 转VS2010解决方案转换到VS2008
- python调用通达信公式_对照通达信一些指标的Python实现
- Java计算两点间经纬度距离(两种方式)
- rxjs里withLatestFrom operators的用法
- 《分布式系统:概念与设计》一2.3.2 体系结构模式
- ANSIC标准定义的6种预定义宏
- SpringBoot开发案例之整合Spring-data-jpa
- KNN算法网格搜索最优参数
- 这个超逼真的虚拟小姐姐,可能是腾讯游戏未来的样子
- F-Scrack 弱口令检测脚本
- 1067 Sort with Swap(0, i) (25 分) 好,容易出错
- [UNIX]The UNIXHATERS Handbook
- FPGA入门——1位全加器设计
- 蓝桥杯 等差素数列(python实现)
- Mac电脑怎样网络在线重装系统
- Hans Berger脑电图之父的人生摘要
- 数据库的锁有哪几种?语句怎么实现
- 用计算机唱黑人台湾音乐,运用计算机音乐技术的音乐教学
- meta是什么意思中文_Meta 的意思是什么?
- 奋斗者——一个高级咨询师是怎样炼成的
热门文章
- python3.6安装ipython_centos6.5下安装python3.6、pip、ipython
- androidstudio build tools安装_Android Studio4.0 安装及配置
- Kafka:集群部署
- MIP 组件库升级公告
- 大型网站的HTTPS实践:基于协议和配置的优化
- Docker+Nginx部署Angular国际化i18n
- 我的这套VuePress主题你熟悉吧
- python练习笔记——利用信号signal处理僵尸进程
- 1.django 开发环境搭建
- 企业Shell面试题18:单词及字母去重排序案例