Visualizzazione dei risultati da 1 a 3 su 3

Discussione: Cerca in una frase

  1. #1

    Cerca in una frase

    Salve ragazzi, devo verificare se in una frase esiste almeno una delle parole indicate in un'altra frase; MI SPIEGO:
    ho la seguente frase:"Ciao bella, come stai? Ti ho cercato tutto il giorno."
    E voglio vedere se nella frase è contenuta almeno una delle parole della seconda frase: "ho mangiato"
    Nell'esempio fatto dovrebbe tornarmi True perche "ho" è presente.

    Spero di essere stato chiaro...
    Grazie.

  2. #2
    Codice PHP:
    <?php
    $mystring 
    'abc';
    $findme   'a';
    $pos strpos($mystring$findme);

    // Note our use of ===.  Simply == would not work as expected
    // because the position of 'a' was the 0th (first) character.
    if ($pos === false) {
        echo 
    "The string '$findme' was not found in the string '$mystring'";
    } else {
        echo 
    "The string '$findme' was found in the string '$mystring'";
        echo 
    " and exists at position $pos";
    }

    ?>
    Prova cosi

  3. #3
    Scusa ma nel caso di
    stringa1="Ciao come stai?"
    stringa2="Ciao stai bene?"
    Ritornerebbe false
    Invece mi deve tornare true perchè esiste nella stringa1 due parole della stringa2

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.