• 20-02-2023, 17:18:31
    #10
    ytscript adlı üyeden alıntı: mesajı görüntüle
    Hocam bize hatanın ss'ini atarsan daha iyi yardımcı olabiliriz
    Hata şu ,. eğer senin kendi yazdığın foreach'ı koyarsam sayfa boşa düşüyor.
  • 20-02-2023, 17:19:30
    #11
    AndyCap adlı üyeden alıntı: mesajı görüntüle
    $content'in temsili örneğini ekler misiniz?
    Content'in içinden, h1 h2 h3 h4 h5 h6 ve " deneme text " gelmekte. tiny ile
  • 20-02-2023, 17:25:52
    #12
    Hocam regex'i ve contenti şu sitede deneyip sonucu bizimle paylaşır mısınız?
    https://regexr.com/

    adım adım gidelim
    regexte hata olmadığını doğrulayalım.

    Siteye girdikten sonra ilk kutuya regexi 2. kutuya da contenti yazın sağ altta list dedikten sonra sonuçlar çıkacaktır. No result dönerse regexte hata vardır.

    örnek:
  • 20-02-2023, 17:32:32
    #13
    Merhaba.

    Regex doğru çalışıyor
  • 20-02-2023, 17:53:42
    #14
    Kimlik doğrulama veya yönetimden onay bekliyor.
    <?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>";
    }
    foreach ($cikti[0] as $key => $element) {
        $title = $cikti[1][$key];
        $eski_tag = $element; 
        $yeni_tag = "<h$key id='" . seo($title) . "'>"; 
     
        $content = str_replace($eski_tag, $yeni_tag . $title . "</h$key>", $content);
    }
  • 20-02-2023, 17:56:34
    #15
    
    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);
    }
  • 20-02-2023, 17:58:51
    #16
    adwerd0z1 adlı üyeden alıntı: mesajı görüntüle
    
    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.
  • 20-02-2023, 18:00:48
    #17
    AndyCap adlı üyeden alıntı: mesajı görüntüle
    <?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>";
    }
    foreach ($cikti[0] as $key => $element) {
        $title = $cikti[1][$key];
        $eski_tag = $element; 
        $yeni_tag = "<h$key id='" . seo($title) . "'>"; 
     
        $content = str_replace($eski_tag, $yeni_tag . $title . "</h$key>", $content);
    }
    Warning: preg_match_all(): Unknown modifier 'h' in
    Notice: Trying to access array offset on value of type null in
    Warning: Invalid argument supplied for foreach() in
    Notice: Trying to access array offset on value of type null in
    Warning: Invalid argument supplied for foreach() in
    Hatalarını almaktayım. Veriyi getiriyor h leri doğru sıralıyor fakat ilk forwach yanlış dönüyor
    @adwerd0z1;
  • 20-02-2023, 18:06:40
    #18
    iltu33 adlı üyeden alıntı: mesajı görüntüle
    Warning: preg_match_all(): Unknown modifier 'h' in
    Notice: Trying to access array offset on value of type null in
    Warning: Invalid argument supplied for foreach() in
    Notice: Trying to access array offset on value of type null in
    Warning: Invalid argument supplied for foreach() in
    Hatalarını almaktayım. Veriyi getiriyor h leri doğru sıralıyor fakat ilk forwach yanlış dönüyor
    @adwerd0z1;
    preg_match_all('/<h[1-6]>(.*?)<\/h[1-6]>/', $content, $cikti);
    
    if (!empty($cikti[0])) {
        foreach ($cikti[1] as $title) {
            echo '<a href="#' . seo($title) . '" onclick="goAnchor(' . seo($title) . ')">' . $title . '</a>' . "<br>";
        }
    
        foreach ($cikti[0] as $key => $element) {
            $title = $cikti[1][$key];
            $newElement = '<h' . ($key + 1) . ' id="' . seo($title) . '">' . $title . '</h' . ($key + 1) . '>';
            $content = str_replace($element, $newElement, $content);
        }
    }