Visualizzazione dei risultati da 1 a 7 su 7
  1. #1

    Funzioni applicate a parole

    Ciao. AVrei bisogno di fare qualcosa di simile ad un codice fiscale. In pratica ho

    3 parole. dalle prima due estrapolo solo le consonanti, dalla terza le prime due lettere.

    Conoscete qlk funzione utile? grazie mille..ciaoo
    http://codecanyon.net/category/all?ref=Manuelandro
    And I bet she told a million people that she'd stay in touch, Well all the little promises they dont mean much,When theres
    memories to be made

  2. #2
    Utente di HTML.it L'avatar di nicola75ss
    Registrato dal
    Nov 2004
    Messaggi
    12,923
    Codice PHP:
    function codice($stringa){
    preg_match_all("#\\w+#",$stringa,$words);
        if ( 
    count($words[0]) < 3) {
            echo 
    'meno di 3 parole';
            return 
    false;
        }
        
    $vocali = array("a""e""i""o""u""A""E""I""O""U");
        
    $str '';
        for (
    $i=0;$i<=1;$i++) {
        
    $str.= str_replace($vocali,'',$words[0][$i]);
        }
        
    $str.= substr($words[0][2],0,2);
        return 
    $str;


  3. #3
    Originariamente inviato da nicola75ss
    Codice PHP:
    function codice($stringa){
    preg_match_all("#\\w+#",$stringa,$words);
        if ( 
    count($words[0]) < 3) {
            echo 
    'meno di 3 parole';
            return 
    false;
        }
        
    $vocali = array("a""e""i""o""u""A""E""I""O""U");
        
    $str '';
        for (
    $i=0;$i<=1;$i++) {
        
    $str.= str_replace($vocali,'',$words[0][$i]);
        }
        
    $str.= substr($words[0][2],0,2);
        return 
    $str;

    scusami, le 3 paole nn sono una stringa, ma 3 variabili diverse
    http://codecanyon.net/category/all?ref=Manuelandro
    And I bet she told a million people that she'd stay in touch, Well all the little promises they dont mean much,When theres
    memories to be made

  4. #4
    Utente di HTML.it L'avatar di nicola75ss
    Registrato dal
    Nov 2004
    Messaggi
    12,923
    Originariamente inviato da Manuelandro
    scusami, le 3 paole nn sono una stringa, ma 3 variabili diverse
    Codice PHP:
    $parola1 'pippo';
    $parola2 'pluto';
    $parola3 'paperino';

    $vocali = array("a""e""i""o""u""A""E""I""O""U");
    $str str_replace($vocali,'',$parola1);
    $str.= str_replace($vocali,'',$parola2);
    $str.= substr($parola3,0,2);
    echo 
    $str

  5. #5
    grazie mille. sei stato gentilissimo.
    Un ultimo chiarimento se posso, devo completare questa sorta di codice fiscale inserendo nella stringa anche una data formattata e cioè

    ppppltpa + 151206 (presi dal campo data 2006-12-15)


    come faccio?
    grazie ancora per l'aiuto!
    http://codecanyon.net/category/all?ref=Manuelandro
    And I bet she told a million people that she'd stay in touch, Well all the little promises they dont mean much,When theres
    memories to be made

  6. #6
    Utente di HTML.it L'avatar di nicola75ss
    Registrato dal
    Nov 2004
    Messaggi
    12,923
    Codice PHP:
    $data '2006-12-15';
    $arr explode('-',$data);
    $str $arr[2].$arr[1].substr($arr[0],2,2);
    echo 
    $str

  7. #7
    mito
    http://codecanyon.net/category/all?ref=Manuelandro
    And I bet she told a million people that she'd stay in touch, Well all the little promises they dont mean much,When theres
    memories to be made

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.