array_key_exists($key, $array) vs !empty($array[$key])
问题 I've seen a lot of people do the former, is there any performance benefit doing one vs the other? Or is it just an eye candy? I personally use the latter every time as it is shorter and personally more readable to me. 回答1: The other responses focus on the differences between the two functions. This is true, but if the source array does not contain null or 0 or "" , ... (empty values) values you can benchmark the speed of the two functions: <?php function makeRandomArray( $length ) { $array =