#47276 [Opn->Bgs]: array_change_value_case

From: Date: Mon, 02 Feb 2009 14:21:44 +0000
Subject: #47276 [Opn->Bgs]: array_change_value_case
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-133381@lists.php.net to get a copy of this message
 ID:               47276
 Updated by:       johannes@php.net
 Reported By:      david at ramaboo dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         Feature/Change Request
 Operating System: all
 PHP Version:      5.2.8
 New Comment:

We already have way too many array functions which makes it hard to
find relevant ones in the docs. We decided not to implement new ones,
which can be implemented trivially in userland code.


Previous Comments:
------------------------------------------------------------------------

[2009-02-02 11:26:04] david at ramaboo dot com

Description:
------------
There is a function array_change_key_case but not
array_change_value_case. This should be part of the language.

Something like this:
/**
 * @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;
	}
}



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=47276&edit=1



Thread (2 messages)

« previous php.bugs (#133381) next »