PHP array_key_exists() 与array_keys() 函数使用方法与实例教程我们先来看看
array_key_exists()定义和用法
该array_key_exists ( )函数检查一个数组某一特定键,返回true ,如果存在的关键和虚假的关键是不存在。
语法
array_key_exists(key,array)
Parameter Description key Required. Specifies the key array Required. Specifies an array
提示和说明提示:请记住,如果您跳过的关键当您指定一个数组,一个整数产生的关键是开始,在0和1增加为每个价值。(见例 )<?php
$a=array("a"=>"Dog","b"=>"Cat");
if (array_key_exists("a",$a))
{
echo "Key exists!";
}
else
{
echo "Key does not exist!";
}
?>
输出结果.
Key exists!
再来看个实例吧.
<?php
$a=array("Dog",Cat");
if (array_key_exists(0,$a))
{
echo "Key exists!";
}
else
{
echo "Key does not exist!";
}
?>
输出结果.
Key exists!
好了下面我们来接着讲array_keys() 函数使用方法
定义和用法该array_keys ( )函数返回一个数组包含的钥匙。 语法 array_keys(array,value)
Parameter Description array Required. Specifies an array value Optional. You can specify a value, then only the keys with this value are returned strict Optional. Used with the value parameter. Possible values: true - Returns the keys with the specified value, depending on type: the number 5 is not the same as the string "5".false - Default value. Not depending on type, the number 5 is the same as the string "5".
来看个例子.
<?php
$a=array("a"=>"Horse","b"=>"Cat","c"=>"Dog");
print_r(array_keys($a));
?>
输出结果.
Array ( [0] => a [1] => b [2] => c )
韩剧再婚皇后阿里云盘全集高清1080P资源链接-韩剧再婚皇后免费阿里云盘资源下载4K高清无删减版链接
poipiku网站如何打开-poipiku官网网页版访问入口
明日方舟:终末地-云游戏畅玩入口-明日方舟:终末地-网页版在线直连地址
poki在线小游戏网页版-poki免费游戏大全入口
poki游戏入口-点开即玩-poki游戏-在线免费畅玩
原神akt大佬资源viciNeko入口链接-原神akt大佬资源网页vicineko入口链接分享