by_grafitus adlı üyeden alıntı: mesajı görüntüle
Denemedim ama çalışır sanırım:
<?php
 
$text = 'ali, ayşeyi çok severdi. Ama ayşe, aliyi sevmezdi. Çünkü ali çok pisdi.';
$replaces = array(
    0 => 'veli',
    1 => 'ahmet',
    2 => 'kemal',
);
 
preg_match_all('~(ali)~i', $text, $matches);
$matches_count = count($matches[1]);
 
for ($i = 0; $i < $matches_count; $i++)
    $text = str_ireplace($matches[1][$i], $replaces[$i], $text);
 
echo $text;
?>
http://www.myclup.net/test.php hep veli yazdırıyor