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];
$newElement = '<h1 id="' . seo($title) . '">' . $title . '</h1>';
$content = str_replace($element, $newElement, $content);
$newElement = '<h2 id="' . seo($title) . '">' . $title . '</h2>';
$content = str_replace($element, $newElement, $content);
$newElement = '<h3 id="' . seo($title) . '">' . $title . '</h3>';
$content = str_replace($element, $newElement, $content);
$newElement = '<h4 id="' . seo($title) . '">' . $title . '</h4>';
$content = str_replace($element, $newElement, $content);
$newElement = '<h5 id="' . seo($title) . '">' . $title . '</h5>';
$content = str_replace($element, $newElement, $content);
$newElement = '<h6 id="' . seo($title) . '">' . $title . '</h6>';
$content = str_replace($element, $newElement, $content);
} @AndyCap;
@adwerd0z1;
Cevapladığım işlemi direk olarak uyguladığımda, bütün h leri h1 olarak getiriyor.