Merhabalar.
İşlemim veri tabanından gelen konumun ($content), içindeki h1 den h6 ya kadar aldırıp daha sonra bunları,
<h1 id="h1" </h1>
<h1 id="h2" </h1>
...
şeklinde işliyor fakat yazdırırken hepsini <h1> olarak yazdırıyor.
İd'leri farklı oluyor ancak, örneğin benim 2 tane <h2>, 3 tane <h3> 'üm var olsa bile hepsini <h1> olarak basıyor.
Mantık hatam nerede?
preg_match_all('/<h[1-6]>(.*?)<\/h[1-6]>/', $content, $cikti);
foreach($cikti[1] as $title) {
    echo '<a href="#' . seo($title) . '" onclick="goAnchor(' . seo($title) . ')">' . $title . '</a>' . "<br>";
}
// muhtemel hata olan yer
foreach ($cikti[0] as $key => $element) {
    $title = $cikti[1][$key];

    $content = str_replace($element, '<h1 id="' . seo($title) . '">' . $title . '</h1>', $content);
    $content = str_replace($element, '<h2 id="' . seo($title) . '">' . $title . '</h2>', $content);
    $content = str_replace($element, '<h3 id="' . seo($title) . '">' . $title . '</h3>', $content);
    $content = str_replace($element, '<h4 id="' . seo($title) . '">' . $title . '</h4>', $content);
    $content = str_replace($element, '<h5 id="' . seo($title) . '">' . $title . '</h5>', $content);
    $content = str_replace($element, '<h6 id="' . seo($title) . '">' . $title . '</h6>', $content);
}