I'm trying to sanitize some arrays received through $_POST[] and insert them into database. How should I do that?
The html is name="room_types[]"
$room_types = $_POST['room_types'];
how to sanitize this array?
You can use array_map
like this:
$room_types = isset( $_POST['room_types'] ) ? (array) $_POST['room_types'] : array();
$room_types = array_map( 'esc_attr', $room_types ); // Replace esc_attr with your desire sanitization