note 88648 modified in function.array-change-key-case by thiago
| From: | thiago@php.net | Date: | Mon, 02 Feb 2009 12:37:52 +0000 |
| Subject: | note 88648 modified in function.array-change-key-case by thiago | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-150100@lists.php.net to get a copy of this message | ||
Same as array_change_key_case only with the values. This should really be part of PHP!
<?php
/**
* @brief Returns an array with all values lowercased or uppercased.
* @return array Returns an array with all values lowercased or uppercased.
* @param object $input The array to work on
* @param int $case [optional] Either \c CASE_UPPER or \c CASE_LOWER (default).
*/
function array_change_value_case(array $input, $case = CASE_LOWER) {
switch ($case) {
case CASE_LOWER:
return array_map('strtolower', $input);
break;
case CASE_UPPER:
return array_map('strtoupper', $input);
break;
default:
trigger_error('Case is not valid, CASE_LOWER or CASE_UPPER only', E_USER_ERROR);
return false;
}
}
?>
--was--
Same as array_change_key_case only with the values. This should really be part of PHP!
/**
* @brief Returns an array with all values lowercased or uppercased.
* @return array Returns an array with all values lowercased or uppercased.
* @param object $input The array to work on
* @param int $case [optional] Either \c CASE_UPPER or \c CASE_LOWER (default).
*/
function array_change_value_case(array $input, $case = CASE_LOWER) {
switch ($case) {
case CASE_LOWER:
return array_map('strtolower', $input);
break;
case CASE_UPPER:
return array_map('strtoupper', $input);
break;
default:
trigger_error('Case is not valid, CASE_LOWER or CASE_UPPER only', E_USER_ERROR);
return false;
}
}
http://php.net/manual/en/function.array-change-key-case.php