Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 11
  1. #1

    ciclo "for" + ciclo "if"

    $talkdatafile è un file txt con varie righe con vari messaggi.
    Esempio di dati nel file txt:

    codice:
    Vre|ciao|81.x.x.x|azione
    Vre|come va?|81.x.x.x|messaggio

    Non capisco perché non mi riconosce le "if" e non mi segue le instruzioni che ci sono dentro. Grazie.

    Codice PHP:
     <?
    $talks_temp 
    file($talkdatafile);

    $talks array_reverse($talks_temp);

    $showtalks count($talks);


    for (
    $t 0$t $showtalks$t++) {    
    $talk_array explode("|"$talks[$t]);

    if (
    $talk_array[3]=="azione") {
    $font="<font face=\"Book Antiqua\" color=\"#0066FF\">";
    $sfont="</font>";
    }
    if (
    $talk_array[3]=="messaggio") {
    $divisore=" -";
    $font="<font face=\"Book Antiqua\" color=\#99FF00\">";
    $sfont="</font>";

    }


    echo 
    "[b]".$font.$talk_array[0].$sfont."[/b] ";
    echo 
    $talk_array[3];
    echo 
    stripslashes($divisore.$font.$talk_array[1].$sfont)."
    \n"
    ;


    }

    ?>
    GdR Online - http://lenar.it/
    Yesterday is history. Tomorrow is mystery.
    Today is a gift. That's why it's called the present

  2. #2
    unica cosa ti manca un \ " in uno dei due color, a me funziona

  3. #3
    Il bello è che quando faccio scrivere $talk_array[3]; mi ritorna "messaggio"...mmh...se a te gira perché a me no...
    GdR Online - http://lenar.it/
    Yesterday is history. Tomorrow is mystery.
    Today is a gift. That's why it's called the present

  4. #4
    Questo è l'html generato:

    codice:
    <table border="2" cellpadding=0 cellspacing=0 bordercolor="red" width="800">
      <tr> 
        <td bordercolor="#000000" width="104">
    	<div id="scroll3" style="width:700;height:400;overflow:auto">
    
          vre messaggio
    spqw
    
    vre messaggio
    sdfsdfsdf
    
    vre messaggio
    with
    
    vr messaggio
    viauaaaa
    
    vre azione
    aaaaaaa
    
    
    	    </div></td>
    </tr>
    </table>
    GdR Online - http://lenar.it/
    Yesterday is history. Tomorrow is mystery.
    Today is a gift. That's why it's called the present

  5. #5
    <font face="Book Antiqua" color="#0066FF">Bli</font> azione<font face="Book Antiqua" color="#0066FF">ciack</font>

    <font face="Book Antiqua" color=#99FF00">Bli</font> messaggio -<font face="Book Antiqua" color=#99FF00">ciao</font>

    <font face="Book Antiqua" color=#99FF00">Vre</font> messaggio -<font face="Book Antiqua" color=#99FF00">come va?</font>

    <font face="Book Antiqua" color="#0066FF">Vre</font> azione -<font face="Book Antiqua" color="#0066FF">ciao</font>

  6. #6
    Non è normale...
    allora,

    Codice PHP:
    <table border="2" cellpadding=0 cellspacing=0 bordercolor="red" width="800">
      <tr> 
        <td bordercolor="#000000" width="104">
        <div id="scroll3" style="width:700;height:400;overflow:auto">

          <?
          $talks_temp 
    file($talkdatafile);

    $talks array_reverse($talks_temp);

    $showtalks count($talks);


    for (
    $t 0$t $showtalks$t++) {    
    $talk_array explode("|"$talks[$t]);

    if (
    $talk_array[3]==" azione") {
    $font="<font face=\"Book Antiqua\" color=\"#0066FF\">";
    $sfont="</font>";
    }
    if (
    $talk_array[3]=="messaggio ") {
    $divisore=" -";
    $font="<font face=\"Book Antiqua\" color=\"#99FF00\">";
    $sfont="</font>";

    }


    echo 
    "[b]".$font.$talk_array[0].$sfont."[/b] ";
    echo 
    $talk_array[3];
    echo 
    stripslashes($divisore.$font.$talk_array[1].$sfont)."
    \n"
    ;


    }

    ?> 

            </div></td>

        <td valign="top" align="center" bordercolor="#FFFF00">
          <font face="Monotype Corsiva" color="#FFFFFF" size="4"><?print utenti_online();?></font>
        </td>


      </tr>

    </table>
    File di testo:


    codice:
    Barahir|dsasdas|80.x.x.x
    Barahir|sdasdasdddd|80.
    Barahir|saddddsadasd|80.|messaggio
    Barahir|bieni da me|80.|messaggio
    Barahir|blablabla|80.|messaggio
    Barahir|ssssssss|80.|azione
    Barahir|come on|80.|messaggio
    Barahir|ciao|80.|messaggio
    Barahir|ddddddd|80.|attacco
    Barahir|aaaaaaa|80.|azione
    Non credo possa dipendere dal server...e non credo che ci possano entrare altri file o altre parti di codice.
    GdR Online - http://lenar.it/
    Yesterday is history. Tomorrow is mystery.
    Today is a gift. That's why it's called the present

  7. #7
    Ma ogni volta che carica una riga ripassa anche dagli if vero?
    GdR Online - http://lenar.it/
    Yesterday is history. Tomorrow is mystery.
    Today is a gift. That's why it's called the present

  8. #8
    if ($talk_array[3]==" azione") qua c'è uno spazio di troppo
    if ($talk_array[3]=="messaggio ") qua stesso
    consiglio: usa foreach per passare tutto l'array penso venga molto piu comodo

  9. #9
    ho dato un occhio su php.net ma non ho capito come possa usare questo

    Codice PHP:
    foreach ($arr as $value
    GdR Online - http://lenar.it/
    Yesterday is history. Tomorrow is mystery.
    Today is a gift. That's why it's called the present

  10. #10
    Se uso, invece di parole, numeri funziona...

    se metto 1 invece di "messaggio" funziona...è normale?
    GdR Online - http://lenar.it/
    Yesterday is history. Tomorrow is mystery.
    Today is a gift. That's why it's called the present

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.