Guest User

Untitled

a guest
Oct 18th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. <?php
  2. function array_traverse (&$array, $function, $limit=2, $truncate=true) {
  3. foreach ($array as $key => &$value) {
  4. if (is_array($value)) {
  5. if ($limit > 0) {
  6. array_traverse($value, $function, --$limit, $truncate);
  7. } else {
  8. if ($truncate) {
  9. $value = '{truncated}';
  10. }
  11. }
  12. } else {
  13. $value = $function($value, $key);
  14. }
  15. }
  16. }
Add Comment
Please, Sign In to add comment