PHP » PYTHON |
login |
register |
about
|
PYTHON array_change_key_case
is this article helpful?
|
Python replacement for PHP's array_change_key_case
[
edit
| history
]
def dict_change_key_case(input, case=CASE_LOWER): if case == CASE_LOWER: f = str.lower elif case == CASE_UPPER: f = str.upper else: raise ValueError() return dict((f(k), v) for k, v in input.items()) array_change_key_case(PHP 4 >= 4.2.0, PHP 5) array_change_key_case — Changes all keys in an array Description
array array_change_key_case
( array $input
[, int $case= CASE_LOWER
] )
Returns an array with all keys from input lowercased or uppercased. Numbered indices are left as is. Parameters
Return ValuesReturns an array with its keys lower or uppercased, or FALSE if input is not an array. Errors/ExceptionsThrows E_WARNING if input is not an array. Examples
Example #1 array_change_key_case() example
<?phpThe above example will output:
Array
(
[FIRST] => 1
[SECOND] => 4
)
Notes
|
more
Recently updated
more
Most requested
|