Merge a group of arrays


/ Published in: Other
Save to your folder(s)



Copy this code and paste it in your HTML
  1. /**
  2. * Merge a group of arrays
  3. *
  4. * @param array First array
  5. * @param array Second array
  6. * @param array Third array
  7. * @param array Etc...
  8. * @return array All array parameters merged into one
  9. */
  10. function amerge()
  11. {
  12. $r = array();
  13. foreach(func_get_args()as $a)
  14. {
  15. if (!is_array($a))
  16. {
  17. $a = array($a);
  18. }
  19. $r = array_merge($r, $a);
  20. }
  21. return $r;
  22. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.