Skip to content

Instantly share code, notes, and snippets.

@sayedulsayem
Created September 5, 2023 10:22
Show Gist options
  • Save sayedulsayem/b857e33d9442ff19bc28190c1d9b09b9 to your computer and use it in GitHub Desktop.
Save sayedulsayem/b857e33d9442ff19bc28190c1d9b09b9 to your computer and use it in GitHub Desktop.
Sanitize array recursively
<?php
function sanitize_array_recursively( $array ) {
foreach ( $array as $key => &$value ) {
if ( is_array( $value ) ) {
$value = sanitize_array_recursively( $value );
} else {
$value = sanitize_text_field( $value );
}
}
return $array;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment