In PHP, you can use the array_change_key_case() function to convert the array key name (key) to lowercase; this function can convert all the keys (keys) in the array to lowercase letters, you only need to omit the first Two parameters or set the second parameter to "CASE_LOWER", the syntax is "array_change_key_case (array)" or "array_change_key_case (array, CASE_LOWER)".
The operating environment of this tutorial: windows7 system, PHP version 8.1, DELL G3 computer
How to convert the array key name (key) in php for lowercase? Simple!
PHP provides a function: array_change_key_case() to achieve this function. Let's take a look at this function
array_change_key_case() The function can convert all keys of the array into uppercase letters or lowercase letters. Syntax format:
array_change_key_case(array,case);
Description | |
---|---|
Required. Specifies the array to use. | |
Optional. Possible values: |
|
- Just need to set the second parameter of the array_change_key_case() function to " CASE_LOWER", or omit the second parameter.
Implementation code:
<?php header('content-type:text/html;charset=utf-8'); $age=array("Peter"=>"35","Ben"=>"37","Joe"=>"43"); echo "原数组:"; var_dump($age); echo "数组键名(key)转为小写:"; var_dump(array_change_key_case($age)); var_dump(array_change_key_case($age,CASE_LOWER)); ?>
PHP video tutorial 》
The above is the detailed content of How to convert array key name (key) to lowercase in php. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

WebStorm Mac version
Useful JavaScript development tools

SublimeText3 Linux new version
SublimeText3 Linux latest version

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Atom editor mac version download
The most popular open source editor

Dreamweaver CS6
Visual web development tools
