How to capitalize an array by php
I would like to share with you how php capitalizes the array. I hope you will get something after reading this article. Let's discuss it together.
Php will convert the array to uppercase methods: 1, create a PHP sample file; 2, define an associative array; 3, use the foreach statement to traverse the array; 4, use the strtoupper function to capitalize the array elements.
This article operating environment: Windows7 system, PHP7.1 version, DELL G3 computer
How to change the key value to uppercase in PHP associative array
We have an array like this:
$fruits = array ('A' = > 'Apple',' B' = > 'Banana',' c'= > 'Cherry',' o' = > 'Orange')
We capitalize all the array element values in it:
Use the foreach statement to iterate through the $fruits array, and use the strtoupper ($value) function in the loop to uppercase the array element $value, so the output is:
After reading this article, I believe you have a certain understanding of "how php capitalizes arrays". If you want to know more about it, you are welcome to follow the industry information channel. Thank you for reading!