Home > php教程 > php手册 > PHP二维数组 根据条件取数据

PHP二维数组 根据条件取数据

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 10:41:54
Original
1136 people have browsed it

有个数组$point_arr(如下),取出   user_id = 3的那一行数组。
代码如下:
//你的数组
$point_arr = array(
        array("id"=>1,"id"=>1,"point"=>2),
        array("id"=>2,"id"=>3,"point"=>2),
        array("id"=>3,"id"=>3,"point"=>2),
        array("id"=>4,"id"=>3,"point"=>2),
);
for($i = 0;$i         if($point_arr[$i]["id"] == 3){
                //$new是个新的数组用于接收user_id=3的。
                $new[] = $point_arr[$i];
        }
}
//输出新的数组。
for($i = 0;$i         print_r($new[$i]);
        echo "
";
}
?>

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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template