PHP Array Question
Posted: Sun Dec 28, 2003 12:51 am
It's late and I am having braincramps if you were pulling information that spanned many rows in a MySQL table, how would one write it to a multidimensional array, for example...
query:
"SELECT * FROM some_table"
returns:
10 rows
information I need spans 5 columns:
1. question
2. correct answer
3, 4, 5. wrong answers
How can I pull this info into an array such as the one that follows:
so that I end up with all 10 questions and 40 answers in a seperate array(i.e. $questAnswers[0][0] - $questAnswers[9][4], each one being a question and all it's possible answers:
Then I need to be able to shuffle each one, would i just do this using:
Thanks in advance,
Saethyr
query:
"SELECT * FROM some_table"
returns:
10 rows
information I need spans 5 columns:
1. question
2. correct answer
3, 4, 5. wrong answers
How can I pull this info into an array such as the one that follows:
Code: Select all
$questAnswers = array($incrementingnum => array(0 => $question, 1 => $correctans, 2 => $wrongans1, 3 => $wrongans2, 2 => $wrongans3);Then I need to be able to shuffle each one, would i just do this using:
Code: Select all
shuffle($questAnswers[0]);Thanks in advance,
Saethyr