Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Sanitizes input, converting types in $new to the type of that
- * same value in $old. Any keys not in $old will be stripped out.
- * @param array $new New settings.
- * @param array $old Old settings
- * @return array Sanitized version of $new, based on $old.
- */
- private static function sanitizeSettings($new, $old = null) {
- $old = is_null($old) ? self::getSettings() : $old;
- $ret = $old;
- foreach ($old as $k => $v) {
- if (isset($new[$k])) {
- if (is_array($v)) {
- $ret[$k] = self::sanitizeSettings((array)$new[$k], $v);
- } elseif (settype($new[$k], gettype($v))) {
- $ret[$k] = $new[$k];
- }
- }
- }
- return $ret;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement