If I understood the question correctly, and if you even have equal arrays at both ends, you can use the ==
operator. It will return true
when both arrays have the same keys and values:
array('a' => 10, 'b' => 20) == array('b' => 20, 'a' => 10)
In this example with explicit keys, the order is not important. But since in your example the keys are implicit (numeric), you must sort the arrays first. The example still considers that the incoming arrives as a string separated by commas, as you commented:
$entrada = sort(explode($_GET['a']));
$referencia = sort(array('value1', 'value2', 'value3'))
if($entrada == $referencia) ...
See a test
In this case, you can also use ===
, which requires that the values in the arrays have the same keys and types, in the same order (these last two conditions do not apply to ==
).
While the in_array
when it receives an array as the first parameter, it checks if any of its values are contained in the other, and not all are contained in it see example in the manual ).
Reference: PHP Manual Array operators