You are here

public static function ArrayUtils::isList in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/zendframework/zend-stdlib/src/ArrayUtils.php \Zend\Stdlib\ArrayUtils::isList()

Test whether an array is a list

A list is a collection of values assigned to continuous integer keys starting at 0 and ending at count() - 1.

For example: <code> $list = array('a', 'b', 'c', 'd'); $list = array( 0 => 'foo', 1 => 'bar', 2 => array('foo' => 'baz'), ); </code>

Parameters

mixed $value:

bool $allowEmpty Is an empty list a valid list?:

Return value

bool

File

vendor/zendframework/zend-stdlib/src/ArrayUtils.php, line 120

Class

ArrayUtils
Utility class for testing and manipulation of PHP arrays.

Namespace

Zend\Stdlib

Code

public static function isList($value, $allowEmpty = false) {
  if (!is_array($value)) {
    return false;
  }
  if (!$value) {
    return $allowEmpty;
  }
  return array_values($value) === $value;
}