$content değişkenimden tüm konum geliyor.
preg_match_all ile $content değerimden gelen baslıkları alıp foreach ile yazdırıyorum.
<?php
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>";
}
?>Daha sonra bir foreach daha açıp gelen başlıklara str_replace ile bir id tanımlıyorum ve bunu geri $content değişkenime atıyorum ki hem yazılar gelsin, hem gelen başlıklar id'ye sahip olsun.<?php
foreach($cikti[1] as $title) {
$content = str_replace('<h1>', '<h1 id="' . seo($title) . '">' . $title . '</h1>', $content);
$content = str_replace('<h2>', '<h2 id="' . seo($title) . '">' . $title . '</h2>', $content);
$content = str_replace('<h3>', '<h3 id="' . seo($title) . '">' . $title . '</h3>', $content);
$content = str_replace('<h4>', '<h4 id="' . seo($title) . '">' . $title . '</h4>', $content);
$content = str_replace('<h5>', '<h5 id="' . seo($title) . '">' . $title . '</h5>', $content);
$content = str_replace('<h6>', '<h6 id="' . seo($title) . '">' . $title . '</h6>', $content);
}
?>
<?php echo $content; ?>Fakat yanlış yazdırıyor.Ben şu şekilde bir ekleme yapıyorum:

Bana sunduğu çıktı:

Neden olabilir? Hatam nerede olabilir?
