Walks the array while sanitizing the contents.
$input_arrayarrayrequired
function add_magic_quotes( $input_array ) {
foreach ( (array) $input_array as $k => $v ) {
if ( is_array( $v ) ) {
$input_array[ $k ] = add_magic_quotes( $v );
} elseif ( is_string( $v ) ) {
$input_array[ $k ] = addslashes( $v );
}
}
return $input_array;
}
© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/add_magic_quotes