Buon giorno sto cercando attraverso questa funzione di trovare all'interno di un testo due parole, link e allegato.
ho provato in questo modo ma è troppo macchinoso e vorrei sapere cortesemente come posso ottimizzare per trovare tutte le soluzioni.
Codice PHP:
//FARE CONTROLLO SU LINK SE GIà ESISTENTE NON AGGIORNARE-->TROVARE LINK ALL'INTERNO DEL TESTO
if (!preg_match("/p=$healthy[0]/i", $txtTesto)) {
//se non esiste creo link alla pagina
$newphrase = str_replace($healthy, $yummy, stripslashes($txtTesto));
//echo "Se link non esiste lo creo";exit;
}
elseif(!preg_match("/allegato/i", trim($txtTesto))) {
//echo "'$newphrase' contains a 'allegato' or 'Allegato'!";
$newphrase=str_replace("allegato","[url='".$base_dir.$selArgomento."/News/".inv_data(trim($txtDataIns))."/".$phFileAllegato."']allegato[/url]",$newphrase);
//echo "Testo New: " .htmlentities($newphrase);exit;
}
elseif(!preg_match("/p=$healthy[0]/i", $txtTesto) && !preg_match("/allegato/i", trim($txtTesto))) {
//echo "'$newphrase' contains sia link che allegato!";
$newphrase=str_replace("allegato","[url='".$base_dir.$selArgomento."/News/".inv_data(trim($txtDataIns))."/".$phFileAllegato."']allegato[/url]",$newphrase);
//echo "Testo New: " .htmlentities($newphrase);exit;
}
Praticamente, devo controllare se nel testo:
1) è presente solo la parola link
2) solo la parola allegato
3) oppure tutte e due.
e farmi restituire il risultato dalla stessa variabile $newphrase, che poi mi serve per fare un Update.
Potreste dirmi cortesemente come fare?
Io intanto continuo a scervellarmi.
Grazie mille e buona giornata.