Recurse_array_change_key_case () recursion returns an array of string key names that are all lowercase or uppercase _php tutorial

Source: Internet
Author: User
Recursively returns an array of string key names that are all lowercase or uppercase
Function Recurse_array_change_key_case (& $input, $case = case_lower) {
if (!is_array ($input))
Return

foreach ($input as $key = $val)
{
1
if ($case = = Case_upper)
{
$newkey = Strtoupper ($key);
}
0
ElseIf ($case = = case_lower)
{
$newkey = Strtolower ($key);
}

if ($newkey! = $key)
{
Unset ($input [$key]);
$input [$newkey] = $val;
}
if (Is_array ($val))
{
# # #注: The parameters here must be $input[$newkey], not $val, and if $val, $key =>& in foreach $val
Recurse_array_change_key_case ($input [$newkey], $case);
}
}
}

http://www.bkjia.com/PHPjc/752221.html www.bkjia.com true http://www.bkjia.com/PHPjc/752221.html techarticle //Recursive return string key name is all lowercase or uppercase array function recurse_array_change_key_case ($input, $case = case_lower) {if (!is_array ($input)) Return foreach ($input as $key ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.