Core PHP

Array Search Functions

Array Search Functions
array_key_exists()
bool array_key_exists(string|int $xKey, array $qaArray)
This function returns a boolean value to indicate whether $xKey is used as a key in the array $qaArray. The function returns true if the key is used in the array and false if it is not used.
Argument Description
array $qaArray This is the array that is being checked for its key.
string|int $xKey This is the key that we are searching for in $qaArray.
array_key_first()
int|string|null array_key_first(array $qaArray)
This function returns the first key of the array $qaArray.
Argument Description
array $qaArray This is the array from which the first key is taken. If the array is empty, null is returned.
array_key_last()
int|string|null array_key_last(array $qaArray)
This function returns the last key of the array $qaArray.
Argument Description
array $qaArray This is the array from which the last key is taken. If the array is empty, null is returned.
array_rand()
int|string|array array_rand(array $qaArray, int $iNumberReturned = 1)
This function returns $iNumberReturned keys from the array $qaArray. If $iNumberReturned equals 1, an int or string is returned, since these are keys. Otherwise, an array is returned. If $iNumberReturned is larger than the number entries of $qaArray, E_WARNING will be thrown and null will be returned.
Argument Description
array $qaArray The array from which random keys are being taken.
int $iNumberReturned The number of random keys to be returned.
array_search()
int|string|bool array_search(various $qToBeFound, array $qaArray, bool $bStrict = false)
This function returns the key of the entry in the array, if it was found. Otherwise, it returns false. If $bStrict is true, the function will search for the same exact instance, rather than the same value.
Argument Description
various $qToBeFound This is the value that we are searching for in the array.
array $qaArray This is the array that is to be searched.
bool $bStrict This boolean value is false to indicate a search for the same value and true to search for the same instance.
in_array()
bool in_array(various $qToBeFound, array $qaArray, bool $bStrict = false)
This function checks the array $qaArray for the value $qToBeFound and returns true, if it was found. Otherwise, it returns false. If $bStrict is true, the function will chack the type as well as the value.
Argument Description
various $qToBeFound This is the value that we are searching for in the array.
array $qaArray This is the array that is to be searched.
bool $bStrict This boolean value is false to indicate a search for the same value and true to search for the same type and value.
key_exists()
bool key_exists(string|int $xKey, array $qaArray)
This is an alias of array_key_exists(). This function returns a boolean value to indicate whether $xKey is used as a key in the array $qaArray. The function returns true if the key is used in the array and false if it is not used.
Argument Description
array $qaArray This is the array that is being checked for its key.
string|int $xKey This is the key that we are searching for in $qaArray.
 
 

© 2007–2024 XoaX.net LLC. All rights reserved.