3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function array_equal_set() { return count(array_unique(array_map(function ($arr) { return serialize(array_values(array_unique($arr))); }, func_get_args()))) === 1; } $test_cases = array( /* 0 */ array( 'A' , 'B' , 'C' ), /* 1 */ array( 'A' , 'C' , 'B' ), /* 2 */ array( 'B' , 'A' , 'C' ), /* 3 */ array( 'B' , 'C' , 'A' ), /* 4 */ array( 'C' , 'A' , 'B' ), /* 5 */ array( 'C' , 'B' , 'A' ), /* 6 */ array( 'A' , 'B' , 'C' , 'D' ), /* 7 */ array( 'A' , 'B' , 'D' ), /* 8 */ array( 'A' , 'B' , 'B' ), /* 9 */ array( 'A' , 'B' ), /* 10 */ array( 'A' , 'B' , 'C' , 'B' ), ); // test $data = array( 'A' , 'B' , 'C' ); foreach( $test_cases as $key => $test ){ $result = array_equal_set( $test, $data ) ? 'TRUE' : 'FALSE' ; echo "[$key]$result" . PHP_EOL; }
Output for 5.3.0 - 7.1.0
[0]TRUE [1]FALSE [2]FALSE [3]FALSE [4]FALSE [5]FALSE [6]FALSE [7]FALSE [8]FALSE [9]FALSE [10]TRUE
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION, expecting ')' in /in/f7XsU on line 4
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_FUNCTION, expecting ')' in /in/f7XsU on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `')'' in /in/f7XsU on line 4
Process exited with code 255.