3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Check if an array contains any value in a set. ** * @param array $array * @param array $subset * @param bool $strict Strict type checking * @return bool */ $a=array(1,'test'); $b=array(2,'test'); function array_contains_any_val(array $array, array $subset, bool $strict = false) :bool { $contains = false; foreach ($subset as $value) { if (in_array($value, $array, $strict)) { $contains = true; break; } } return $contains; } var_dump(array_contains_any_val($a, $b));
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.31, 8.2.0 - 8.2.27, 8.3.0 - 8.3.16, 8.4.1 - 8.4.3
bool(true)

preferences:
127.85 ms | 407 KiB | 5 Q