PHP two-dimensional array and three-dimensional array of filtering, PHP two-dimensional array _php tutorial

Source: Internet
Author: User
Tags array to string

PHP two-dimensional array and three-dimensional array filter, PHP two-dimensional array of arrays


Not much nonsense to say, directly to everyone to paste the code, 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);

Here is a piece of code to introduce PHP three-dimensional array variable two-dimensional array

<?php$result = Array (0 = = Array (0 = = Array (bid + 41,brealname = ' We instructor ', cid = 41,crealname = ' We instructors '), 1 = = Array (0 = = Array (bid + 6,brealname = ' no ', cid = 19,crealname = ' Zhang Fish ')));//original array print_r ($result ); echo "
";///First method: foreach ($result as $key + $v) {$new _arr[]= $v [0];} Echo '
;p Rint_r ($new _arr);//The second method//Initialize $ARR2 $arr 2=array ();//Loop through a three-dimensional array $arr3 foreach ($result as $value) {foreach ($value as $v) {$arr 2[]= $v;}} Destruction of $arr3 unset ($result, $value, $v); echo "
"; echo "the second method:"; Echo '
;p Rint_ R ($arr 2);? 

About PHP two-dimensional array and three-dimensional array of filtering small series to introduce you so much, I hope you have some help!

!--endmain--> articles you might be interested in:
  • rewrite function to implement PHP two-dimensional/three-dimensional array to string

http://www.bkjia.com/phpjc/1111350.html www.bkjia.com true http://www.bkjia.com/phpjc/1111350.html techarticle php two-dimensional array and three-dimensional array of filtering, PHP two-dimensional array of arrays of nonsense to say, directly to everyone to paste the code, the specific code is as follows: php$ arr = [[,,,,],[,,,,]]; $arr = [' L ...

  • 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.