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

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

$
0
0

try this

$required=['a','b'];$data=['a'=>1,'b'=>2];if(count(array_intersect($required,array_keys($data))>0){    //a key or all keys in required exist in data }else{    //no keys found  }

Viewing all articles
Browse latest Browse all 22

Trending Articles



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