1.array_keys(end($arr))
$array = array(
'one'=>1,
'two'=>2,
'three'=>3,
'four'=>4,
);
$arr = array_keys($array);
var_dump(end($arr));
$array = array(
'one'=>1,
'two'=>2,
'three'=>3,
'four'=>4,
);
$arr = array_keys($array);
var_dump(array_pop($arr));
3.foreach()
$array = array(
'one'=>1,
'two'=>2,
'three'=>3,
'four'=>4,
);
foreach($array as $key => $value){
$temp = $key;
}
var_dump($temp)
4.array_slice
$array = array(
'one'=>1,
'two'=>2,
'three'=>3,
'four'=>4,
);
$arr = array_slice($array,-1,1,true);
var_dump(key($arr));
转载于:https://www.cnblogs.com/bluealine/p/7576306.html