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

Answer by Ravi Shankar S K for How to check if multiple array keys exists

$
0
0
    $colsRequired   = ["apple", "orange", "banana", "grapes"];    $data           = ["apple"=>"some text", "orange"=>"some text"];    $presentInBoth  = array_intersect($colsRequired,array_keys($data));    if( count($presentInBoth) != count($colsRequired))        echo "Missing keys  :" . join(",",array_diff($colsRequired,$presentInBoth));    else        echo "All Required cols are present";

Viewing all articles
Browse latest Browse all 22

Trending Articles



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