Created
February 11, 2014 17:33
-
-
Save wpscholar/8939803 to your computer and use it in GitHub Desktop.
Sanitize a value by passing it through one or more sanitization callbacks.
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 | |
/** | |
* Sanitize a value by passing it through one or more sanitization callbacks. | |
* | |
* @param mixed $value | |
* @param callable|array $sanitize | |
* @return mixed | |
*/ | |
function sanitize( $value, $sanitize ) { | |
$callbacks = is_callable( $sanitize ) ? array( $sanitize ) : (array) $sanitize; | |
foreach ( $callbacks as $callback ) { | |
if ( is_callable( $callback ) ) { | |
$value = call_user_func( $callback, $value ); | |
} | |
} | |
return $value; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment