note 100321 deleted from function.array-flip by danbrown

From: Date: Thu, 07 Oct 2010 21:39:22 +0000
Subject: note 100321 deleted from function.array-flip by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-173070@lists.php.net to get a copy of this message
Note Submitter: _mx_ ---- <?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 ) */ ?>

« previous php.notes (#173070) next »