Php doubles the number of cells in a multi-dimensional array. Php doubles the number of cells in a multi-dimensional array. This article describes how php doubles the number of cells in a multi-dimensional array. I would like to share with you how php doubles the unit value (number) in a multi-dimensional array, doubling the number of dimensions.
This example describes how to double the unit value (number) in a multi-dimensional array in php. Share it with you for your reference. The specific analysis is as follows:
Premise: a multi-dimensional array with each minimum unit value being a number.
Requirement: write a function to double the minimum unit value.
The code is as follows:
<? Php $ arr = array (1, 3, 'a' => 20, 'B' => array (2, 4, 6, 'C' => 7 )); function arr2 ($ arr) {foreach ($ arr as $ key => $ v) {if (! Is_array ($ v) {$ arr [$ key] * = 2;} else {$ arr [$ key] = arr2 ($ arr [$ key]);} return $ arr;} echo"";print_r(arr2($arr));?>
Use the functions provided by the system to solve the problem as follows:
<? Php $ arr = array (1, 3, 'a' => 20, 'B' => array (2, 4, 6, 'C' => 7 )); function t (& $ arr) {$ arr * = 2;} echo"";array_walk_recursive($arr,'t');print_r($arr);?>
I hope this article will help you with php programming.
This article describes how php doubles the number of cells in a multi-dimensional array. Share it with you...