Minwork Array
  • Minwork Array
  • Common methods
    • has
    • get → getNestedElement
    • set → setNestedElement
    • remove
    • clone
    • getKeysArray
  • Object oriented methods
    • General information
  • Traversing array
    • Finding
    • Iterating
  • Manipulating array
    • Mapping
    • Filtering
    • Grouping
    • Sorting
    • Computations
    • Flattening
  • Validating array
    • check
    • isEmpty
    • isNested
    • isArrayOfArrays
    • isAssoc
    • isUnique
    • isNumeric
    • hasKeys
  • Utility methods
    • pack
    • unpack
    • createMulti
    • forceArray
    • getDepth
    • random
    • shuffle
    • nth
    • getFirstKey
    • getLastKey
    • getFirstValue
    • getLastValue
Powered by GitBook
On this page

Was this helpful?

  1. Validating array

hasKeys

Definition

Arr::hasKeys(array $array, mixed $keys, bool $strict = false): bool

Description

Check if array has specified keys ( all required, when $strict is true).

Examples

$array = ['key1' => 1, 'key2' => 2, 'key3' => 3];

Arr::hasKeys($array, ['key2', 'key3']) -> true

Arr::hasKeys($array, 'key1.key2') -> true

Arr::hasKeys($array, ['test', 'key1']) -> true

Arr::hasKeys($array, ['test', 'key1'], true) -> false

Arr::hasKeys($array, 'test') -> false
PreviousisNumericNextpack

Last updated 5 years ago

Was this helpful?