note 119000 added to function.array-merge

From: Date: Tue, 15 Mar 2016 09:10:59 +0000
Subject: note 119000 added to function.array-merge
Groups: php.notes 
Request: Send a blank email to php-notes+get-205165@lists.php.net to get a copy of this message
public function mergeArrays($arrays, $field) { //take array in arrays for retrive structure after merging $clean_array = current($arrays); foreach ($clean_array as $i => $value) { $clean_array[$i]=''; } $merged_array = []; $name = ''; foreach ($arrays as $array){ $array = array_filter($array); //clean array from empty values if ($name == $array[$field]) { $merged_array[$name] = array_merge($merged_array[$name], $array); $name = $array[$field]; } else { $name = $array[$field]; $merged_array[$name] = $array; } } //have to be cleaned from array 'field' signs to return original structure of arrays foreach ($merged_array as $array){ $ready_array[] = array_merge($clean_array, $array); } return $ready_array; } ---- Server IP: 72.52.91.14 Probable Submitter: 81.1.237.122 ---- Manual Page -- http://php.net/manual/en/function.array-merge.php Edit -- https://master.php.net/note/edit/119000 Del: integrated -- https://master.php.net/note/delete/119000/integrated Del: useless -- https://master.php.net/note/delete/119000/useless Del: bad code -- https://master.php.net/note/delete/119000/bad+code Del: spam -- https://master.php.net/note/delete/119000/spam Del: non-english -- https://master.php.net/note/delete/119000/non-english Del: in docs -- https://master.php.net/note/delete/119000/in+docs Del: other reasons-- https://master.php.net/note/delete/119000 Reject -- https://master.php.net/note/reject/119000 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#205165) next »