Quantcast
Channel: How to check if multiple array keys exists - Stack Overflow
Viewing all articles
Browse latest Browse all 22

Answer by iautomation for How to check if multiple array keys exists

$
0
0

The above solutions are clever, but unnecessarily slow. A simple foreach loop over a few keys is much faster.

function array_keys_exist($keys, $array){    foreach($keys as $key){        if(!array_key_exists($key, $array)) {            return false;        }    }    return true;}

Viewing all articles
Browse latest Browse all 22

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>