Home > Backend Development > PHP Tutorial > Summary | PHP multidimensional array filtering method c# multidimensional array matlab multidimensional array multidimensional array pointer

Summary | PHP multidimensional array filtering method c# multidimensional array matlab multidimensional array multidimensional array pointer

WBOY
Release: 2016-07-29 08:50:50
Original
1298 people have browsed it

data-id="1190000005075514" data-license="nd">

Filter function

<code>function my_filter($arr){
    $filterDatum = 'what you set';
    
    foreach($arr as $k => &$item){
        if(is_array($item){
            my_filter($item);
        }else{ // item is an element
            if($item == $filterDatum){
                unset($arr[$k]);
            }
        }
    }
    
    return $arr;
}
</code>
Copy after login

Filter implementation statement

<code>$arr = [
    // who know what the array looks like.
];

$arr = array_filter($arr, 'my_filter');
</code>
Copy after login

BINGO

Reference

  1. Q&A on this site

The above has introduced the summary | PHP multi-dimensional array filtering method, including the content of PHP multi-dimensional arrays. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template