Utiliza colores aleatorios para cada tabla para visualizar mejor cada elemento del array.
Modificar a gusto del consumidor:
Código PHP:
<?php
function print_a($array){
mt_srand((double)microtime()*1000000);
$color = '';
while(strlen($color)<6){
$color .= sprintf("%02X", mt_rand(0, 255));
}
$t = "<table
width=\"100%\"
cellpadding=\"2\"
cellspacing=\"0\"
border=\"1\"
bordercolor=\"".$color."\"
bgcolor=\"".$color."\"
>";
$i = 0;
foreach($array as $key => $value){
$t.="<tr ".($i%2==0?"":"bgcolor=\"#FFFFFF\"").">
<td align=\"center\">$key</td>
<td>".(is_array($value)?print_a($value):"".$value." (".(gettype($value))." ".strlen($value).")")."</td>
</tr>";
$i++;
}
$t .= "</table>";
return $t;
}
/**
* EJEMPLO
*
*/
$array = array(
'0' => 'Cero',
'1' => 'Uno',
'2' => 'Dos',
'3' => array(
'0' => array(
'0' => 'Cero',
'1' => 'Uno',
'2' => 'Dos',
'3' => array(
'0' => 'Cero',
'1' => 'Uno',
'2' => 'Dos',
'3' => array(
'0' => 'Cero',
'1' => 'Uno',
'2' => 'Dos',
'3' => 'Tres'))),
'1' => 'Uno',
'2' => 'Dos',
'3' => 'Tres'),
'4' => 'Cuatro',
'5' => array(
'0' => 'Cero',
'1' => 'Uno',
'2' => 'Dos',
'3' => 'Tres'),
'6' => 'Seis');
echo print_a($array);
?>