Facilmente puedes adaptar estos ejemplos...
Código PHP:
Ver original<?php
0 => 'a1',
1 => 'a2',
2 => 'a3'
),
0 => 'a1',
1 => 'a2',
2 => 'a3'
),
0 => 'a1',
1 => 'a2',
2 => 'a3'
)
);
'a' => 'a1',
'b' => 'a2',
'c' => 'a3'
),
'a' => 'b1',
'b' => 'b2',
'c' => 'b3'
),
'a' => 'c1',
'b' => 'c2',
'c' => 'c3'
),
'a' => 'd1',
'b' => 'd2',
'c' => 'd3'
)
);
echo "<pre>";
echo "</pre>";
$elements=count($foo, COUNT_RECURSIVE
); $elementsFila=($elements-$files)/$files;
echo "<br />elements ".$elements.", ";
echo "files ".$files.", ";
echo "elementsFila ".$elementsFila."<br /><br />";
echo "Array tal cual<br /><br />";
echo "<table border='0' cellspacing='3' cellpadding='0'>";
for($f=0;$f<$files;$f++){
echo "<tr>";
for($e=0;$e<$elementsFila;$e++){
echo "<td>".$foo[$f][$e]."</td>";
}
echo "</tr>";
}
echo "</table>";
echo "<br /><br />";
echo "Array transpuesta<br /><br />";
echo "<table border='0' cellspacing='3' cellpadding='0'>";
for($e=0;$e<$elementsFila;$e++){
echo "<tr>";
for($f=0;$f<$files;$f++){
echo "<td>".$foo[$f][$e]."</td>";
}
echo "</tr>";
}
echo "</table>";
echo "<br /><br />";
echo "Array invertida<br /><br />";
echo "<table border='0' cellspacing='3' cellpadding='0'>";
for($f=$files-1;$f>=0;$f--){
echo "<tr>";
for($e=$elementsFila-1;$e>=0;$e--){
echo "<td>".$foo[$f][$e]."</td>";
}
echo "</tr>";
}
echo "</table>";
echo "<br /><br />";
echo "<pre>";
echo "</pre>";
$elements=count($foo2, COUNT_RECURSIVE
); $elementsFila=($elements-$files)/$files;
echo "<pre>";
echo "</pre>";
echo "<br />elements ".$elements.", ";
echo "files ".$files.", ";
echo "elementsFila ".$elementsFila."<br /><br />";
echo "Array tal cual<br /><br />";
echo "<table border='0' cellspacing='3' cellpadding='0'>";
for($f=0;$f<$files;$f++){
echo "<tr>";
for($e=0;$e<count($claus);$e++){ echo "<td>".$foo2[$f][$claus[$e]]."</td>";
}
echo "</tr>";
}
echo "</table>";
echo "<br /><br />";
echo "Array transpuesta<br /><br />";
echo "<table border='0' cellspacing='3' cellpadding='0'>";
for($e=0;$e<count($claus);$e++){ echo "<tr>";
for($f=0;$f<$files;$f++){
echo "<td>".$foo2[$f][$claus[$e]]."</td>";
$foo3[$claus[$e]][$f]=$foo2[$f][$claus[$e]];
}
echo "</tr>";
}
echo "</table>";
echo "<br /><br />";
echo "Array invertida<br /><br />";
echo "<table border='0' cellspacing='3' cellpadding='0'>";
for($f=$files-1;$f>=0;$f--){
echo "<tr>";
for($e=count($claus)-1;$e>=0;$e--){ echo "<td>".$foo2[$f][$claus[$e]]."</td>";
}
echo "</tr>";
}
echo "</table>";
echo "<br /><br />Aqui tenemos foo3 que es foo2 transpuesta<br /><br />";
echo "<pre>";
echo "</pre>";