Skip to content
Snippets Groups Projects
Commit fdeb756e authored by Olav Morken's avatar Olav Morken
Browse files

Utilities: Added transposeArray-function.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@261 44740490-163a-0410-bde0-09ae8108e29a
parent 115a55b8
No related branches found
No related tags found
No related merge requests found
......@@ -410,6 +410,34 @@ class SimpleSAML_Utilities {
/* End script execution. */
exit;
}
/**
* This function transposes a two-dimensional array, so that
* $a['k1']['k2'] becomes $a['k2']['k1'].
*
* @param $in Input two-dimensional array.
* @return The transposed array.
*/
public static function transposeArray($in) {
assert('is_array($in)');
$ret = array();
foreach($in as $k1 => $a2) {
assert('is_array($a2)');
foreach($a2 as $k2 => $v) {
if(!array_key_exists($k2, $ret)) {
$ret[$k2] = array();
}
$ret[$k2][$k1] = $v;
}
}
return $ret;
}
}
?>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment