<?php
//Есть массив
$arr=['a','d','x','d','d','d','a','z','z','f','f','f','f','b','c','v'];
echo '<div>' . PHP_EOL;
foreach ($arr as $i=>$el) {
if ($i > 0 && $el <> $arr[$i - 1] ) echo '</dv><div>' . PHP_EOL;
echo $el . PHP_EOL;
}
echo '</div>';