Home > php教程 > php手册 > php array_change_key_case用法详解

php array_change_key_case用法详解

WBOY
Release: 2016-06-21 08:53:15
Original
1365 people have browsed it

array_change_key_case ----返回字符串键名全为小写或大写的数组
说明:
 

array array_change_key_case ( array $input [, int $case ] )

array_change_key_case()input 数组中的所有键名改为全小写或大写。改变是根据后一个选项 case 参数来进行的。可以在这里用两个常量,CASE_UPPERCASE_LOWER。默认值是 CASE_LOWER。本函数不改变数字索引。

Example #1 array_change_key_case() 例子

<span style="color: rgb(0,0,0)"><font face="NSimsun"><span style="color: rgb(0,0,187)"><?php <br/> $input_array </span><span style="color: rgb(0,119,0)">= array(</span><span style="color: rgb(221,0,0)">"FirSt" </span><span style="color: rgb(0,119,0)">=> </span><span style="color: rgb(0,0,187)">1</span><span style="color: rgb(0,119,0)">, </span><span style="color: rgb(221,0,0)">"SecOnd" </span><span style="color: rgb(0,119,0)">=> </span><span style="color: rgb(0,0,187)">4</span></font><font face="NSimsun"><span style="color: rgb(0,119,0)">);<br> </span><span style="color: rgb(0,0,187)">print_r</span><span style="color: rgb(0,119,0)">(</span><span style="color: rgb(0,0,187)">array_change_key_case</span><span style="color: rgb(0,119,0)">(</span><span style="color: rgb(0,0,187)">$input_array</span><span style="color: rgb(0,119,0)">, </span><span style="color: rgb(0,0,187)">CASE_UPPER</span></font><font face="NSimsun"><span style="color: rgb(0,119,0)">));<br> </span><span style="color: rgb(0,0,187)">?></span> </font></span>

上例将输出:

Array<br>(<br>    [FIRST] => 1<br>    [SECOND] => 4<br>)<br>
Copy after login

如果一个数组中的多个键名经过本函数后变成一样的话(例如 "keY" 和 "kEY"),最后一个值将覆盖其它的值。


 



Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template