Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function array_traverse (&$array, $function, $limit=2, $truncate=true) {
- foreach ($array as $key => &$value) {
- if (is_array($value)) {
- if ($limit > 0) {
- array_traverse($value, $function, --$limit, $truncate);
- } else {
- if ($truncate) {
- $value = '{truncated}';
- }
- }
- } else {
- $value = $function($value, $key);
- }
- }
- }
Add Comment
Please, Sign In to add comment