Bolt\Helpers\Arr::isIndexedArray PHP Method

isIndexedArray() public static method

This is the same as isIndexed but it does not check if array is zero-indexed and has sequential keys.
Deprecation: since 3.3, to be removed in 4.0.
public static isIndexedArray ( array $arr ) : boolean
$arr array
return boolean True if indexed, false if associative
    public static function isIndexedArray(array $arr)
    {
        foreach ($arr as $key => $val) {
            if ($key !== (int) $key) {
                return false;
            }
        }
        return true;
    }

Usage Example

Example #1
0
 /**
  * Get the return value from the callable.
  *
  * Parameters can be can handled in three ways:
  *   - null              - Nothing passed to the callback
  *   - Indexed array     - Value of each element will be passed to function in order
  *   - Associative array - Key names will attempt to match to the callable function variable names
  */
 protected function invokeCallable(callable $callback, $callbackArguments)
 {
     if ($callbackArguments === null) {
         return call_user_func($callback);
     }
     if (Arr::isIndexedArray($callbackArguments)) {
         return call_user_func_array($callback, (array) $callbackArguments);
     }
     $orderedArgs = $this->getArguments($callback, $callbackArguments);
     return call_user_func_array($callback, $orderedArgs);
 }
All Usage Examples Of Bolt\Helpers\Arr::isIndexedArray