This article introduces the filtering of PHP two-dimensional arrays and three-dimensional arrays, which involves the knowledge of changing php 3D arrays to two-dimensional arrays. This article describes in detail and has reference value, if you are interested in learning it together, I will not talk about it anymore. I will directly post code to you. The specific code is as follows:
<?php$arr = [[,,,,],[,,,,]];$arr = ['list' => [[,,,],[,,,],[,,,],]];$arr = ['list' => [[,,,],[,,,],[,,,]]];$res = array_map(function($arr){return array_filter($arr, function($v) {return $v !== ;});}, $arr);$res = array_map(function($val) {return array_filter($val, function($v) {return !in_array(, $v);});}, $arr);$res = [];array_walk($arr, function($val, $key) use(&$res) {$res[$key] = array_filter($val, function($v) {return !in_array(, $v);});});var_dump($res);var_dump($res);
The following code describes how to change php 3D arrays to 2D arrays.
<? Php $ result = Array (0 => Array (0 => Array (bid => 41, brealname => 'we instructor ', cid => 41, crealname => 'we instructor '), 1 => Array (0 => Array (bid => 6, brealname => 'tiger sub', cid => 19, crealname => 'zhang Yu '); // original array print_r ($ result); echo"
"; // Method 1: foreach ($ result as $ key => $ v) {$ new_arr [] = $ v [0];} echo''; Print_r ($ new_arr); // method 2 // initialize $ arr2 $ arr2 = array (); // cyclically traverse 3D arrays $ arr3 foreach ($ result as $ value) {foreach ($ value as $ v) {$ arr2 [] = $ v ;}} // destroy $ arr3 unset ($ result, $ value, $ v); echo"
"; Echo" Method 2: "; echo'';print_r($arr2);?>
I would like to introduce so much to you about the filtering of PHP 2D arrays and 3D arrays. I hope it will be helpful to you!