ho risolto utilizzando la funzione str_pos per le due opzioni cosi:
$findme = 'href=\"'.$healthy[0].'\"';
$pos = strpos($txtTesto, $findme);
if ($pos !== false) {
$txtTesto = str_replace($healthy, $yummy, stripslashes($txtTesto));
}
$findme = "allegato";
$pos = strpos($txtTesto, $findme);
if ($pos !== false) {
if($phFileAllegato!="" || $txtPhAllegato!=""){
$txtTesto=str_replace("allegato","<a href='".$base_dir.$selArgomento."/News/".inv_data(trim($txtDataIns))."/".$phFileAllegato."' onclick=\"window.open(this.href);return false;\" title=\"$txtAllegato\">allegato</a>",$txtTesto);
}
}
echo htmlentities($txtTesto);exit;
Cosi facendo sembra prendere tutte le soluzioni.
grazie comunque a tutti...