I want to check if an array only contains allowed element values (are available in another array).
Example:
$allowedElements = array(\'apple\', \'ora
You can use array_intersect() as suggested here. Here's a little function:
function CheckFunction($myArr, $allowedElements)
{
$check = count(array_intersect($myArr, $allowedElements)) == count($myArr);
if($check) {
return "Input array contains only allowed elements";
} else {
return "Input array contains invalid elements";
}
}