3v4l.org

run code in 500+ PHP versions simultaneously
<?php $arr1 = ['foo', 'bar', 'baz', 'foo']; $arr2 = ['foo', 'bar', 'baz', 'bar']; $intersect = array_intersect($arr1, $arr2); var_dump(count($intersect) === count($arr1) && count($arr1) === count($arr2)); var_dump($intersect);
Output for 7.1.25 - 7.1.28, 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.34, 8.2.0 - 8.2.32, 8.3.0 - 8.3.33, 8.4.1 - 8.4.24, 8.5.0 - 8.5.9
bool(true) array(4) { [0]=> string(3) "foo" [1]=> string(3) "bar" [2]=> string(3) "baz" [3]=> string(3) "foo" }

preferences:
81.79 ms | 1474 KiB | 4 Q