wordpress sanitize array?

Here’s a way to do it with PHP’s array map function:

// Good idea to make sure things are set before using them
$tags = isset( $_POST['tags'] ) ? (array) $_POST['tags'] : array();

// Any of the WordPress data sanitization functions can be used here
$tags = array_map( 'esc_attr', $tags );

Leave a Comment