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

    scrivere un array solo se una variabile esiste

    Stampo il contenuto di un file di testo con:

    Codice PHP:
    echo $talk_array[0];
    echo 
    stripslashes($talk_array[1])."\n"
    Il file di testo è strutturato in più righe...come faccio a far scrivere solamente le righe nelle quali un'altra variabile dell'array ($talk_array[2]) non esiste?
    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
    Utente di HTML.it
    Registrato dal
    Apr 2004
    Messaggi
    3,709
    ehm... che vuol dire? Puoi essere più chiaro?

  3. #3
    Sì, scusa...allora...
    il file di testo è così strutturato:

    codice:
    Vre|ciao|kurt
    Io|ciaz|
    Catilina|czxxxo|
    Vre|ciaccczo|nirvana
    Vre|asddddao|kurt
    Con il codice postato prima faccio vedere l'utente che ha scritto e quello che scrive. Vorrei, però, che si vedesse solamente i messaggi dove il terzo array non esiste (nirvana e kurt qui)...ogni utente potrà vedere tutti i messaggi dove il terzo array non esiste o dove esso è uguale al proprio nome(il nome dell'utente è in una variabile di sessione).
    Spero di essere stato chiaro :bubu:
    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
    Utente di HTML.it
    Registrato dal
    Apr 2004
    Messaggi
    3,709
    Codice PHP:
    if ( !(isset($talk_array[2])) OR ($talk_array[2]=='') OR ($talk_array[2]==$NOME_UTENTE) ) {
       echo 
    $talk_array[0];
       echo 
    stripslashes($talk_array[1])."\n";
    }; 
    ma intendi questo?

  5. #5
    Bene...domanda...ogni volta che cambia riga cercando gli array ripete il ciclo if?
    GdR Online - http://lenar.it/
    Yesterday is history. Tomorrow is mystery.
    Today is a gift. That's why it's called the present

  6. #6
    Utente di HTML.it
    Registrato dal
    Apr 2004
    Messaggi
    3,709
    se ho ben capito... sì.

    c'è il ciclo che legge il file e DENTRO il codice con l'if:

    Codice PHP:
    ...INIZIALIZZAZIONE FILE...
    INIZIO_CICLO
       LEGGO RIGA I
    -esima
       
    if ( !(isset($talk_array[2])) OR ($talk_array[2]=='') OR ($talk_array[2]==$NOME_UTENTE) ) {
          echo 
    $talk_array[0];
          echo 
    stripslashes($talk_array[1])."\n";
       };
    FINE_CICLO
    ...CHIUSURA... 
    è questo?

  7. #7
    Esatto.
    Grazie.
    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.