Skip to content
This repository has been archived by the owner on Aug 24, 2019. It is now read-only.

Commit

Permalink
add default to arr::build_assoc
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Morey committed Mar 27, 2009
1 parent d2e3b9d commit d63149c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions helpers/MY_arr.php
Expand Up @@ -35,17 +35,18 @@ public static function get($key, $array, $default = FALSE, $return_default_when_
/**
* build_assoc
*
* initializes an associative array to NULL
* initializes an associative array to a value
*
* @param array $keys the keys of the associative array
* @param array $default value to initialize to
* @return array the resulting array
* @author Kevin Morey
*/
function build_assoc(array $keys)
function build_assoc(array $keys, $default = NULL)
{
$arr = array();

foreach ($keys as $key) { $arr[$key] = NULL; }
foreach ($keys as $key) { $arr[$key] = $default; }

return $arr;
}
Expand Down

0 comments on commit d63149c

Please sign in to comment.