Skip to content

Commit

Permalink
fixed: is_collection() helper function
Browse files Browse the repository at this point in the history
  • Loading branch information
nahid committed Nov 5, 2019
1 parent e77a046 commit 8373d94
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions helpers/presento.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,14 @@ function get_from_array($map, string $node)
/**
* Check given value is multidimensional array
*
* @param mixed $arr
* @param mixed $array
* @return bool
*/
function is_collection($arr) : bool
function is_collection($array) : bool
{
if (!is_array($arr)) {
return false;
}

$first = reset($arr);
//$key = key($first);
if (!is_array($array)) return false;

return isset($first) && is_array($first);
return array_keys($array) === range(0, count($array) - 1);
}
}

Expand Down

0 comments on commit 8373d94

Please sign in to comment.