I'd thought I'd flesh out what I mean by this function. This is the PHP array_keys() function, and a couple of examples, and the returned output:
Code:
array_keys( array $input, mixed $search_value = NULL, bool $strict = false )
Required Args:
1: < array $input > - An array containing keys to return.
Additional Args:
2: < mixed $search_value = NULL > - If specified, then only keys containing these values are returned.
3: < bool $strict = false > - Determines if strict comparison (===) should be used during the search.
INPUT:
Code:
<?php
$array = array(0 => 100, "color" => "red");
print_r(array_keys($array));
$array = array("blue", "red", "green", "blue", "blue");
print_r(array_keys($array, "blue"));
$array = array("color" => array("blue", "red", "green"),
"size" => array("small", "medium", "large"));
print_r(array_keys($array));
?>
OUTPUT:
Code:
Array
(
[0] => 0
[1] => color
)
Array
(
[0] => 0
[1] => 3
[2] => 4
)
Array
(
[0] => color
[1] => size
)
The COD4 getArrayKeys() seems to operate with 1 argument and returns the key with its corresponding value (element). When using this function, the array is flipped. So, you have to count down from the top of the array like this:
Code:
{
keys = getArrayKeys( array );
for( i = keys.size-1; i >= 0; i-- )
{
if( arg == keys[i] )
return true;
return false;
}
}
It would be really nice and handy to have a function like this in COD2. Only, as I said, there is no way to parse the keys in an array with COD script, only the value. Someone please prove me wrong!