Given a JSONArray with several JSONObects inside with the following structure:
[
{"Id_temp":"1","temperatura":"20","Insertado_temp":"2016-08-16 12:30:29"},
{"Id_press":"1","presion":"34","Insertado_press":"2016-08-16 16:18:36"},
{"Id_press":"1","presion":"34","Insertado_press":"2016-08-16 16:18:36"},
{"Id_temp":"1","temperatura":"20","Insertado_temp":"2016-08-16 12:30:29"},
{"Id_temp":"2","temperatura":"25","Insertado_temp":"2016-08-16 15:48:53"},
{"Id_press":"2","presion":"34","Insertado_press":"2016-08-16 16:18:36"},
{"Id_temp":"4","temperatura":"50","Insertado_temp":"2016-08-16 18:17:33"},
{"Id_temp":"1","temperatura":"20","Insertado_temp":"2016-08-16 12:30:29"}
]
I have obtained from the following code:
array_push($result,array(
//Pushing name and id in the blank array created
"Id_temp"=>$row['Id_temp'],
"temperatura"=>$row['temperatura'],
"Insertado_temp"=>$row['Insertado_temp'],
"Id_press"=>$row['Id_press'],
"presion"=>$row['presion'],
"Insertado_press"=>$row['Insertado_press']
));
$result1 = array_unique ($result);
}
echo json_encode(array('result'=>$result1));
mysqli_close($con);
I wish in PHP to delete the objects that have duplicate Id_temp and Id_press and to save it again in an array. I've tried it with "array_unique" and "array_values" but it did not work for me. Someone could give me an example based on this one that I describe. Thank you very much