Visualizzazione dei risultati da 1 a 4 su 4

Visualizzazione discussione

  1. #3
    Utente di HTML.it L'avatar di Grino
    Registrato dal
    Oct 2004
    Messaggi
    739
    Un esempio vale più di mille parole.

    Codice PHP:
    <?php
        $stringa 
    "Ciao a tutti è bello avervi qui.";
        
        
    //cambio la stringa nella sua sequenza numerica
        
    $seq_num = array();
        
    $lunghezza strlen($stringa);
        for(
    $i 0$i<$lunghezza$i++)
            
    $seq_num[] = ord($stringa{$i});
            
        
    //ricostruisco la stringa partendo dalla sequenza numerica
        
    $stringaRicostruita="";
        for(
    $i=0$i<$lunghezza;$i++)
            
    $stringaRicostruita.=chr($seq_num[$i]);
            
    ?>
    <!DOCTYPE html>
    <html>
        <head>
            <title></title>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <?php
                
    echo <<<EOT
            <p>$stringaRicostruita</p>
            <p>Questa sopra è la stringa prodotta a partire dal seguente array di byte</p>
    EOT;
                
    var_dump($seq_num);
            
    ?>
        </head>
        <body>
            
        </body>
    </html>
    che produce

    codice:
    Ciao a tutti è bello avervi qui.
    
    Questa sopra è la stringa prodotta a partire dal seguente array di byte
    
    array (size=33)
      0 => int 67
      1 => int 105
      2 => int 97
      3 => int 111
      4 => int 32
      5 => int 97
      6 => int 32
      7 => int 116
      8 => int 117
      9 => int 116
      10 => int 116
      11 => int 105
      12 => int 32
      13 => int 195
      14 => int 168
      15 => int 32
      16 => int 98
      17 => int 101
      18 => int 108
      19 => int 108
      20 => int 111
      21 => int 32
      22 => int 97
      23 => int 118
      24 => int 101
      25 => int 114
      26 => int 118
      27 => int 105
      28 => int 32
      29 => int 113
      30 => int 117
      31 => int 105
      32 => int 46
    Ultima modifica di Grino; 21-11-2014 a 11:08
    Siamo sempre troppo gelosi delle nostre grandi piccole opere! - Grino inedito.
    Lavori e Lavoretti

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 © 2025 vBulletin Solutions, Inc. All rights reserved.