creative-2008
Weaksauce
- Joined
- Dec 23, 2008
- Messages
- 100
I'm running a while loop in PHP which I would like to add variables to an array. I've googled this and searched the PHP manual extensively, and either haven't found it or haven't realised that I've found it!
This is an exert from the code that I'm running:
However, I've tried printing the whole array later and I don't think that I'm actually storing the data in the array correctly. I think that it is instead just storing the last data inputted into the array. The final line of code only prints a value when $num_question is 1.
Can anybody point out to me what I've got wrong? Or where I can find information about arrays that I'm more likely to understand than the PHP handbook.
This is an exert from the code that I'm running:
PHP:
While ($current_question <= $num_question):
$multiplicand = array($current_question => rand(1,12),);
print_r($multiplicand[$current_question]);
print_r($multiplier[$current_question]);
$current_question = ($current_question + 1);
endwhile;
print_r($multiplicand['1']);
However, I've tried printing the whole array later and I don't think that I'm actually storing the data in the array correctly. I think that it is instead just storing the last data inputted into the array. The final line of code only prints a value when $num_question is 1.
Can anybody point out to me what I've got wrong? Or where I can find information about arrays that I'm more likely to understand than the PHP handbook.