note 100321 added to function.array-flip
| From: | _mx_ at osu1 dot php dot net | Date: | Thu, 07 Oct 2010 21:30:50 +0000 |
| Subject: | note 100321 added to function.array-flip | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-173069@lists.php.net to get a copy of this message | ||
<?php
function array_mult_flip($array){
$result = array();
foreach($array as $key => $subArray){
$result += array_combine(array_values($subArray), array_fill(0, count($subArray), $key));
}
return $result;
}
$array1 = array(
'a' => array(1,2,3),
'b' => array(4,5,6),
'c' => array(7,8,9)
);
print_r(array_mult_flip($array1));
/*
Array
(
[1] => a
[2] => a
[3] => a
[4] => b
[5] => b
[6] => b
[7] => c
[8] => c
[9] => c
)
*/
?>
----
Server IP: 189.126.97.120
Probable Submitter: 201.52.38.108
----
Manual Page -- http://www.php.net/manual/en/function.array-flip.php
Edit -- https://master.php.net/note/edit/100321
Del: integrated -- https://master.php.net/note/delete/100321/integrated
Del: useless -- https://master.php.net/note/delete/100321/useless
Del: bad code -- https://master.php.net/note/delete/100321/bad+code
Del: spam -- https://master.php.net/note/delete/100321/spam
Del: non-english -- https://master.php.net/note/delete/100321/non-english
Del: in docs -- https://master.php.net/note/delete/100321/in+docs
Del: other reasons-- https://master.php.net/note/delete/100321
Reject -- https://master.php.net/note/reject/100321
Search -- https://master.php.net/manage/user-notes.php