1

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?

1 Answer 1

0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.