Se io ho 9 variabili numeriche. Come le stampo in ordine decrescente in modo del tutto automatico?
thx
Se io ho 9 variabili numeriche. Come le stampo in ordine decrescente in modo del tutto automatico?
thx
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
Codice PHP:
$array = array();
$array[] = $var1;
$array[] = $var2;
$array[] = $var3;
$array[] = $var4;
$array[] = $var5;
$array[] = $var6;
$array[] = $var7;
$array[] = $var8;
$array[] = $var9;
sort($array);
foreach($array as $value)
echo "$value
";
potresti copiare il contenuto delle variabili in un array ed usare una funzione tipo arsort()
me li stampain ordine ASC
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
grazie ad intra,bi per l'aiuto. Un ultima domanda. se volessi salvare un'altra variabile nello stesso array? me ne serve uno bidimensionale?
thx
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
L'istruzione
$array[] = $var;
Aggiunge un elemento alla fine dell'array. Dopo di che lo puoi sempre riordinare con
sort($array);
Se vuoi che i campi siano NUMERICI puoi fare un cast di tutti gli elementi quando valorizzi l'array, in questo modo
$array[] = (int)$var;
Originariamente inviato da Manuelandro
grazie ad intra,bi per l'aiuto. Un ultima domanda. se volessi salvare un'altra variabile nello stesso array? me ne serve uno bidimensionale?
thx
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
mi spiego meglio. La soluzione dell'array è ottima. Ora però dovrei assegnare ad ogni variabile anche un nome quindei avere
80 Antonio
70 Francesco
etc etc..
come faccio?
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
mmhhhh...
$nomi=array();
$nomi[70]="Antonio";
se vuoi visualizzare tutti valori dell' array
foreach ($nomi as $key=>$val)
{
echo $key." - ".$val;
}
ti visualizzarà
70 - Antonio.
Spero ti possa essere stato utile... la cosa però non potrà funzionare se anche Pippo ha 70...
Non sempre essere l'ultimo è un male... almeno non devi guardarti le spalle
il mio profilo su PHPClasses e il mio blog laboweb
no a me serve qualcosa di abbinato alla risposta che mik hanno dato in precedenza!
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