Created
March 23, 2013 11:50
-
-
Save kahagon/5227430 to your computer and use it in GitHub Desktop.
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 base64_encode_recursively($target) { | |
| if (is_array($target)) { | |
| foreach ($target as $key => $value) { | |
| $target[$key] = base64_encode_recursively($value); | |
| } | |
| return $target; | |
| } else if (is_object($target)) { | |
| $property_list = get_object_vars($target); | |
| foreach ($property_list as $key => $value) { | |
| $target->{$key} = base64_encode_recursively($value); | |
| } | |
| return $target; | |
| } else if (is_null($target)) { | |
| return null; | |
| } else if (is_string($target)) { | |
| switch (mb_detect_encoding($target)) { | |
| case 'ASCII': case 'UTF-8': | |
| return $target; | |
| default: | |
| return base64_encode($target); | |
| } | |
| } else { | |
| return $target; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment