"how can i check if an array contains a specific value in php?" Code Answer

2

Use the in_array() function.

$array = array('kitchen', 'bedroom', 'living_room', 'dining_room');

if (in_array('kitchen', $array)) {
    echo 'this array contains kitchen';
}
By jreed121 on September 24 2022

Answers related to “how can i check if an array contains a specific value in php?”

Only authorized users can answer the search term. Please sign in first, or register a free account.