PHP two-dimensional array obtains data based on conditions. There is an array $ point_arr (as shown below) to retrieve the array of user_id3. The code is as follows :? Php your array $ point_arrarray (array (id1, id1, point2), array (id2, id3, there is an array $ point_arr (as follows), get the array of user_id = 3.
The code is as follows:
// Your array
$ 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 is a new array used to receive user_id = 3.
$ New [] = $ point_arr [$ I];
}
}
// Output a new array.
For ($ I = 0; $ I Print_r ($ new [$ I]);
Echo"
";
}
?>
Extract (as follows), and retrieve the array of user_id = 3. The code is as follows :? Php // your array $ point_arr = array ("id" = 1, "id" = 1, "point" = 2), array ("id" = 2, "id" = 3 ,...