for ($a=0;$a<=(count($dati)-1);$a+2)
{
for ($b=$a;$b<=($a+2);$b++)
{
codice che gestisce $dati[$b];
}
}



credo funzioni.... non l' ho provato.