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

    Stampare un'array con una sola variabile

    Salve a tutti.
    Volevo chiedere se fosse possibile stampare il contenuto di un array con una sola variabile.
    Apparentemente è una cavolata quella che ho detto, mi spiego meglio.

    Ho un array che ricava le chiavi di ricerca di un referrer proveniente da un motore di ricerca.

    Ricavate le chiavi, con un cliclo foreach le recupero tutte.
    Quando però devo registrare il referer se uso $value mi stampa solo l'ultima.

    Codice PHP:

    $url 
    getenv("HTTP_REFERER");
    $keywords ExtractKeywords($url);
    if (
    $keywords != "") {
    foreach (
    $keywords as $value) {
    $key $value;
    }
    }
    $referer "[img]mdr/$quas_ref.gif[/img]$quas_ref - " "Chiavi di ricerca: " "$key"
    Ciao!

  2. #2
    puoi incollare la pagina precedente? ricorda ke nel form devi specificare ke siano elementi di un array! di solito in un form si usa mettere nel name "nome_variabile[]"
    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

  3. #3
    Utente di HTML.it
    Registrato dal
    Sep 2002
    Messaggi
    460
    Ti stampa solo l'ultima perche' sovrascrivi n volte il valore $key
    There are 10 types of people in the world - those who understand binary and those who don't.

  4. #4
    Quello che vgliono dire è che $key non è un array ma una semplice variabile.

    Codice PHP:
    $url getenv("HTTP_REFERER");
    $keywords ExtractKeywords($url);
    if (
    $keywords != "") {
    foreach (
    $keywords as $value) {
    $key[] = $value;
    }
    }
    $referer "[img]mdr/$quas_ref.gif[/img]$quas_ref - " "Chiavi di ricerca: " "$key"
    Ora è un array ma stai perdendo tempo. Quello che serve a te non è un array ma un concatenamento:

    Codice PHP:
    $url getenv("HTTP_REFERER");
    $keywords ExtractKeywords($url);
    if (
    $keywords != "") {
    $key '' ;
    foreach (
    $keywords as $value) {
    $key .= ' - ' $value;
    }
    }
    $referer "[img]mdr/$quas_ref.gif[/img]$quas_ref - " "Chiavi di ricerca: " "$key"
    Ora dovrebbe andare. Ciao!
    eCommerceRS.NET - Commerciante, vendi on-line!
    Il mio nick è mircov e non mirco!!!

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.