PHP filters 2D arrays and 3D arrays, and php 2D arrays _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
PHP filters 2D arrays and 3D arrays, and php 2D arrays. PHP filters two-dimensional arrays and three-dimensional arrays. php two-dimensional array 1? Php23 $ arr [4 [, 9], 5 [, 0] 6]; 7 $ arr2 [8 list [9 [,], 10 [2, 4, 6, 8], 11 [3, 2, 9, PHP filters two-dimensional array and three-dimensional array, php two-dimensional array
 1 
  [ 9             [1,3,5,7],10             [2,4,6,8],11             [3,2,9,0],12         ]13     ];14     $arr3 = [15         'list' => [16             [1,3,5,7],17             [2,4,6,8],18             [3,2,9,0]19         ]20     ];21 22     $res = array_map(function($arr){23         return array_filter($arr, function($v) {24             return $v !== 5;25         });26     }, $arr);27 28     $res2 = array_map(function($val) {29         return array_filter($val, function($v) {30             return !in_array(6, $v);31         });32     }, $arr2);33 34     $res3 = [];35     array_walk($arr3, function($val, $key) use(&$res3) {36         $res3[$key] = array_filter($val, function($v) {37             return !in_array(6, $v);38         });39     });40 41     var_dump($res2);42     var_dump($res3);

Http://www.bkjia.com/PHPjc/1109848.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/1109848.htmlTechArticlePHP filter 2D array and 3D array, php 2D array 1? Php 2 3 $ arr = [4 [1, 3, 5, 7, 9], 5 [2, 4, 6, 0] 6]; 7 $ arr2 = [8 'list' = [9 [1, 3, 5, 7], 10 [2, 4, 6, 8], 11 [3, 2, 9 ,...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.