I started PHP few days ago so sorry if my question is stupid, but there is something I do not understand. Thank you in advance for your indulgence.
In fact, I try to make a foreach loop that adds all the values of a variable Array ($ result) and register it in a variable non-Array ($ nb_vote).
So that's what I did, but it does not and I do not understand why:
Code:
$ fp_resultat_sondage = fopen ( "resultat_sondage.txt", "r");
rewind ($ fp_resultat_sondage);
$ lecture_resultat = fread ($ fp_resultat_sondage, filesize ( "resultat_sondage.txt"));
fclose ($ fp_resultat_sondage);
$ result = explode (",", $ lecture_resultat);
foreach ($ results as $ value) (
echo $ value. "<br />";
$ nb_vote $ nbvote + = $ value;
)
echo $ nb_vote;
The result values are $ 31, 50 and 63.
But at the end of the script, the browser displays only 63.
Bookmarks