• 09-04-2010, 16:28:11
    #1
    Merhaba arkadaşlar
    Bir kelimeden sonra br etiketi eklemek istiyorum.

    burada asp ile yazılmış bir fonksiyon var bunu nasıl php ye cevirebiliriz

    Function Temizle_issim(strInput)
    strInput = Replace(strInput,"2.", "<br>2.")
    strInput = Replace(strInput,"3.", "<br>3.")
    strInput = Replace(strInput,"4.", "<br>4.")
    strInput = Replace(strInput,"5.", "<br>5.")
    strInput = Replace(strInput,"6.", "<br>6.")
    Temizle_issim = strInput
    End Function
  • 09-04-2010, 16:37:12
    #2
    function temizle_issim($strInput) {
    $strInput = str_replace('2.', '<br>2.',$strInput); 
    $strInput = str_replace('3.', '<br>3.',$strInput); 
    $strInput = str_replace('4.', '<br>4.',$strInput); 
    $strInput = str_replace('5.', '<br>5.',$strInput); 
    $strInput = str_replace('6.', '<br>6.',$strInput); 
    return $strInput;
    }
  • 09-04-2010, 16:38:08
    #3
    function temizle($temizle){
        $temizle = str_replace('2.','<br>2.',$temizle);
        $temizle = str_replace('3.','<br>3.',$temizle);
        $temizle = str_replace('4.','<br>4.',$temizle);
        $temizle = str_replace('5.','<br>5.',$temizle);
        $temizle = str_replace('6.','<br>6.',$temizle);
        return $temizle; 
    }
    Tamam yaptım arkadaşlar konu silineiblir.
  • 10-04-2010, 17:34:42
    #4
    Kimlik doğrulama veya yönetimden onay bekliyor.
    Bilgi olması bakımından, str_replace'nin bu şekilde defalarca kullanılması hem gereksiz, hem performans için iyi olmaz. Ya değişiklikleri array olarak yapmalı:

    $eski = array('2.', '3.', '4.', '5.', '6.');
    $yeni = array('<br>2.', '<br>3.', '<br>4.', '<br>5.', '<br>6.');
    $temizle = str_replace($eski,$yeni,$temizle);
    gibi, ya da böyle benzer değişiklikler için direk preg_replace ile halletmeli :

    echo preg_replace('/([0-9]\.)/smi',"<br/>$1",$metin);