note 34380 added to function.array-merge
| From: | tobias_mik at hotmail dot com | Date: | Fri, 25 Jul 2003 10:14:02 +0000 |
| Subject: | note 34380 added to function.array-merge | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-52629@lists.php.net to get a copy of this message | ||
This function merges any number of arrays and maintains the keys:
function array_kmerge ($array) {
reset($array);
while ($tmp = each($array))
{
if(count($tmp['value']) > 0)
{
$k[$tmp['key']] = array_keys($tmp['value']);
$v[$tmp['key']] = array_values($tmp['value']);
}
}
while($tmp = each($k))
{
for ($i = $start; $i < $start+count($tmp['value']); $i
++)$r[$tmp['value'][$i-$start]] = $v[$tmp['key']][$i-$start];
$start = count($tmp['value']);
}
return $r;
}
----
Manual Page -- http://www.php.net/manual/en/function.array-merge.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+34380
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+34380&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+34380&report=yes