protected static function WebformArrayHelper::getKey in Webform 6.x
Same name and namespace in other branches
- 8.5 src/Utility/WebformArrayHelper.php \Drupal\webform\Utility\WebformArrayHelper::getKey()
Get next or prev(ious) array key.
Parameters
array $array: An array.
string $key: A array key.
string $direction: The direction of the key to retrieve.
Return value
string|null The next or prev(ious) array key or NULL if no key is found.
See also
http://stackoverflow.com/questions/6407795/get-the-next-array-item-using...
2 calls to WebformArrayHelper::getKey()
- WebformArrayHelper::getNextKey in src/
Utility/ WebformArrayHelper.php - Get the next key in an array.
- WebformArrayHelper::getPreviousKey in src/
Utility/ WebformArrayHelper.php - Get the prev(ious) key in an array.
File
- src/
Utility/ WebformArrayHelper.php, line 176
Class
- WebformArrayHelper
- Provides helper to operate on arrays.
Namespace
Drupal\webform\UtilityCode
protected static function getKey(array $array, $key, $direction) {
$array_keys = array_keys($array);
$array_key = reset($array_keys);
do {
if ($array_key == $key) {
return $direction($array_keys);
}
} while ($array_key = next($array_keys));
return NULL;
}