Assign the first character into a variable. Before printing out new article-header, check if it's same character.
If not, then print linebreak or whatever and save new first character.
Like:
// Initialize with empty or 'A'
$char = '';
// Fetch data from db
while ($x = fetching_something())
{
// Compare
if ($x{0} != $char)
{
$char = $x{0};
echo '<p>'; // or something
}
echo $x;
}
Note, that this compares case-insensitively...
-Lurius