时间:2021-07-01 10:21:17 帮助过:7人阅读
<?php $a=array("a"=>"Horse","b"=>"Cat","c"=>"Dog"); print_r(array_keys($a)); ?>
输出:
Array ( [0] => a [1] => b [2] => c )
例子 2
使用 value 参数:
<?php $a=array("a"=>"Horse","b"=>"Cat","c"=>"Dog"); print_r(array_keys($a,"Dog")); ?>输出:
<?php $a=array(10,20,30,"10"); print_r(array_keys($a,"10",false)); ?>
输出:
Array ( [0] => 0 [1] => 3 )
例子 4
使用 strict 参数 (true):
<?php $a=array(10,20,30,"10"); print_r(array_keys($a,"10",true)); ?>
输出:
Array ( [0] => 3)
更多php数组函数序列之array_keys() - 获取数组键名相关文章请关注PHP中文网!