<?php

$text = "<b>lorem</b>
description 1

<b>lorem</b>
description 2

<b>lorem</b>
description 3

<b>lorem</b>
description 4

<b>lorem</b>
description 5

<b>lorem</b>
description 6";


$i = 1;
$matches = null;

while (true) {
    
    $text = preg_replace('|<(/)?b>|', ('<\1h'.$i.'>'), $text, 2, $matches);
    
    if (!$matches) {
        break;        
    }
    
    if ($i < 4) $i++;
    $matches = null;
    
}

echo $text;
