- There is an array $point_history (as shown below), take out the array row with user_id = 3.
- The code is as follows:
- //Your array
- $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 is a new array used to receive user_id=3.
- $new[] = $point_history[$row];
- }
- }
- //Output the new array.
- for($row = 0;$row print_r($new[$row]);
- echo "
";
- }
Copy Code
|