Onetastic Macro Documentation >
>
>
Array_ValueExists Array_ValueExists
Returns whether a given value exists or not in the given array. A variable is passed to the last parameter to retrieve the key associated with the value if exists.
Syntax
Bool Array_ValueExists(
Array array,
Mixed value,
out Mixed key)
Parameters
- Array array
- Array to look for the value in.
- Mixed value
- Value to look for.
- out Mixed key
- If the value is found, the key is stored in this variable. If the value appears more than once in the array first found key is returned.
Examples
$array = Array(2, 4, 6, "apple", "banana", "strawberry", 4, 2)
$foundBanana = Array_ValueExists($array, "banana", $key)
$found4 = Array_ValueExists($array, 4, $key)
$found5 = Array_ValueExists($array, 5, $key)
|