I have a form that submits the data in array format. I have sanitized all the data and also tried to escape it using esc_attr
, but it is a function of escaping and not sanitizing.
Is there a better way to sanitize the entire array (with text value) instead of each individual value.
$array = array_map( 'esc_attr', $array );
How can we make sure the data is sanitize and not just escaped?
I have a form that submits the data in array format. I have sanitized all the data and also tried to escape it using esc_attr
, but it is a function of escaping and not sanitizing.
Is there a better way to sanitize the entire array (with text value) instead of each individual value.
$array = array_map( 'esc_attr', $array );
How can we make sure the data is sanitize and not just escaped?
I'm not completely sure what you mean to do, but are you looking for sanitize_text_field
?
$array = array_map( 'sanitize_text_field', $array );