Created
September 5, 2023 10:22
-
-
Save sayedulsayem/b857e33d9442ff19bc28190c1d9b09b9 to your computer and use it in GitHub Desktop.
Sanitize array recursively
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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