You are here

public static function WebformArrayHelper::keysExist in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/Utility/WebformArrayHelper.php \Drupal\webform\Utility\WebformArrayHelper::keysExist()

Checks if multiple keys exist in an array.

Parameters

array $array: An associative array.

array $keys: Keys.

Return value

bool TRUE if multiple keys exist in an array.

See also

https://wpscholar.com/blog/check-multiple-array-keys-exist-php/

1 call to WebformArrayHelper::keysExist()
WebformLibrariesManager::areElementsExcluded in src/WebformLibrariesManager.php
Determine if a library's elements are excluded.

File

src/Utility/WebformArrayHelper.php, line 265

Class

WebformArrayHelper
Provides helper to operate on arrays.

Namespace

Drupal\webform\Utility

Code

public static function keysExist(array $array, array $keys) {
  $count = 0;
  foreach ($keys as $key) {
    if (array_key_exists($key, $array)) {
      $count++;
    }
  }
  return count($keys) === $count;
}