How do I check if received data match one of the values in an array

Hello,
I receive a data with the method:


$data = $_POST['data'];

I want to check if the data received match one of these values in an array:


$array = array(
	"foo" => "foo",
	"bar" => "bar",
);

I want the result to be like this:


if ( $data == $array ) {
	// do something
} else {
	// return
}

How do I achieve this and thanks in advance.

The function that you’re looking for is array_search()

Thank you

@ketting00 ;
Try,

in_array()

also…

Thank you solidcodes

I think in_array() better suits my need. It’s the first time that I learn that PHP also case-sensitive.