Quantcast
Viewing all articles
Browse latest Browse all 22

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

I use something like this quite often

$wantedKeys = ['story', 'message'];$hasWantedKeys = count(array_intersect(array_keys($source), $wantedKeys)) > 0

or to find the values for the wanted keys

$wantedValues = array_intersect_key($source, array_fill_keys($wantedKeys, 1))

Viewing all articles
Browse latest Browse all 22

Trending Articles



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