jQuery style extend in PHP


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



Copy this code and paste it in your HTML
  1. /**
  2.  * jquery style extend, merges arrays (without errors if the passed values are not arrays)
  3.  *
  4.  * @return array $extended
  5.  **/
  6. function extend() {
  7. $args = func_get_args();
  8. $extended = array();
  9. if(is_array($args) && count($args)) {
  10. foreach($args as $array) {
  11. if(is_array($array)) {
  12. $extended = array_merge($extended, $array);
  13. }
  14. }
  15. }
  16. return $extended;
  17. }
  18.  

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.