<?php $haystack = array( "id" => 1, "char1" => 2, "char2" => 3, "char3" => 4, ); $needles = array(2, 4); function in_array_all($needles, $haystack) { unset($haystack['id']); return empty(array_diff($needles, $haystack)); } $exists = in_array_all([2, 4], $haystack); // true var_dump($exists); $exists = in_array_all([1, 3], $haystack); // true var_dump($exists); print_r($haystack);
You have javascript disabled. You will not be able to edit any code.