PHP to double the value of each cell (number) in a multidimensional array, double-fold
The example in this paper is about how to double the value (number) of each cell in a multidimensional array in PHP. Share to everyone for your reference. The specific analysis is as follows:
Premise: A multidimensional array, each of its smallest cell values is a number.
Requirement: Write a function that doubles 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 "";p Rint_r (ARR2 ($arr));? >
Use the functions provided by the system to solve the following methods:
<?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 ');p Rint_r ($arr);?
Hopefully this article will help you with your PHP programming.
http://www.bkjia.com/phpjc/959118.html www.bkjia.com true http://www.bkjia.com/phpjc/959118.html techarticle php the method of doubling the value (number) of each cell in a multidimensional array, doubling This example describes how PHP doubles each cell value (number) in a multidimensional array. Share to everyone for ...