a::missing($array, $required = array())

Checks if a given element is empty.

  • $array (array)
    The source array
  • $required (array)
    An array of required keys
  • return (array)
    An array of empty fields. If this is empty, nothing is missing.

This methods checks if an element is empty. And element is empty if the key does not exist or the value evaluates to false.

Example

<?php

$array = [
  'cat' => 'miao',
  'dog' => 'wuff',
  'bird' => 'tweet',
  'hippo' => null
];

$required = ['cat', 'elephant', 'hippo'];

$missing = a::missing($array, $required);
// missing: ['elephant', 'hippo'];