James James - 1 month ago 12
PHP Question

Is value In_array?

I had a php function that checked for the presence of a URL parameter in the

$old_example
array. This was all working fine, I have made some changes which modified the array (now looks like
$array
) into a multi dimensional array.

Can I not use in_array with an array like this? Any help would be appreciated, I simply need the find value function to see if tje SRID parameter is in first level of
$array


$old_example = array(
'RDfLnNCEsxxGzp6z7CUPX7OZGZqdfsGrHtfj'
);

$array = array(1) {
["RDfLnNCEsxxGzp6z7CUPX7OZGZqdfsGrHtfj"]=>
array(2) {
[0]=>
string(9) "example1"
[1]=>
string(10) "example2"
}
}


// Find Value Function

if (in_array($_GET['srid'], $array)) {
echo "value found";
}

Fky Fky
Answer

http://php.net/manual/fr/function.array-keys.php

if (in_array($_GET['srid'], array_keys($array))) {
  echo "value found";
}