note 106857 deleted from function.array-fill-keys by danbrown

From: Date: Tue, 03 Jan 2012 22:15:31 +0000
Subject: note 106857 deleted from function.array-fill-keys by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-185342@lists.php.net to get a copy of this message
Note Submitter: comments at htmlcompressor dot com ---- I needed a PHP 4 equivalent function to behave the same way as the version for PHP 5 does, so I made the following function: <?php if (!function_exists('array_fill_keys')) { function array_fill_keys($keys, $value) { if (!is_array($keys)) { trigger_error('array_fill_keys() expects parameter 1 to be array, ' . gettype($keys) . ' given', E_USER_WARNING); return; } $filled_array = array(); foreach($keys as $key) { $filled_array[$key] = $value; } return $filled_array; } } ?>

« previous php.notes (#185342) next »