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

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-13 10:41:541138browse

有个数组$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 "
";
}
?>

Statement:
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