- array_count_values: documentation ( source)
- implode: documentation ( source)
- array_keys: documentation ( source)
- ksort: documentation ( source)
- str_split: documentation ( source)
<?php
$list = str_split('ABCDEFGHIJK');
$collecte = array_keys($list);
for($i=0;$i<100;$i++)
{
$shuffle = $list;
array_shuffle($shuffle);
foreach($shuffle as $pos=>$letter)
$collecte[$pos][]=$etter;
}
foreach($collecte as $pos=>$collection)
$collecte[$pos] = array_count_values($collection);
$table=array();
foreach($collecte as $pos=>$collection)
foreach($list as $letter)
$table[$letter][$pos]='<td>'.$collection[$letter].'</td>';
echo '<table>';
foreach($table as $letter=>$ligne)
{
ksort($table[$letter]);
echo '<tr>'.implode('',$table[$letter]).'</tr>';
}
echo '</table>';