Home > Backend Development > PHP Tutorial > 求解一题!

求解一题!

WBOY
Release: 2016-06-23 14:04:06
Original
962 people have browsed it

$arr=array(
   array('id'=>1,'title'=>'分类1'),
   array('id'=>3,'title'=>'分类3'),
   array('id'=>2,'title'=>'分类2'),
   array('id'=>8,'title'=>'分类8'),
   array('id'=>111,'title'=>'分类111'),
);

删除上述 数组中  id=2 的数组 (也就是array('id'=>2,'title'=>'分类2'))


回复讨论(解决方案)

$arr=array(   array('id'=>1,'title'=>'分类1'),   array('id'=>3,'title'=>'分类3'),   array('id'=>2,'title'=>'分类2'),   array('id'=>8,'title'=>'分类8'),   array('id'=>111,'title'=>'分类111'),);foreach($arr as $k=>$v) if($v['id'] == 2) unset($arr[$k]);print_r($arr);
Copy after login
Array
(
    [0] => Array
        (
            [id] => 1
            [title] => 分类1
        )

    [1] => Array
        (
            [id] => 3
            [title] => 分类3
        )

    [3] => Array
        (
            [id] => 8
            [title] => 分类8
        )

    [4] => Array
        (
            [id] => 111
            [title] => 分类111
        )

)

非常感谢二楼,高手  佩服

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