php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #47276 array_change_value_case
Submitted: 2009-02-02 11:26 UTC Modified: 2009-02-02 14:21 UTC
From: david at ramaboo dot com Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 5.2.8 OS: all
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: david at ramaboo dot com
New email:
PHP Version: OS:

 

 [2009-02-02 11:26 UTC] 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;
	}
}


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-02-02 14:21 UTC] johannes@php.net
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.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 13 02:01:32 2024 UTC