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