时间:2021-07-01 10:21:17 帮助过:21人阅读
<?php $a=array("a"=>"Dog","b"=>"Cat"); if (array_key_exists("a",$a)) { echo "Key exists!"; } else { echo "Key does not exist!"; } ?>
输出:
Key exists!
例子 2
<?php $a=array("a"=>"Dog","b"=>"Cat"); if (array_key_exists("c",$a)) { echo "Key exists!"; } else { echo "Key does not exist!"; } ?>
输出:
Key does not exist!
例子 2
<?php $a=array("Dog",Cat"); if (array_key_exists(0,$a)) { echo "Key exists!"; } else { echo "Key does not exist!"; } ?>
输出:
Key exists!
更多php数组函数序列之array_key_exists() - 查找数组键名是否存在相关文章请关注PHP中文网!