Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法通过它的键选择一个数组元素,而不必遍历集合array_keys($arr)- ?
array_keys($arr)
谢谢!
如果你想通过它的键来选择一个元素,你所做的就是:
<?php echo $array_name['KEY_NAME']; ?>
其中“KEY_NAME”是您赋予数组中该元素的键。
很抱歉错误地提出了这个问题,但现在找到了一个久违的解决方案!只需用于array_key_exists($key, $array)测试 $array 中的 $key。
array_key_exists($key, $array)