Answer the question
In order to leave comments, you need to log in
How to make index exception from shuffle function?
I have an array that displays a question and an answer, all questions have an index of 0,
and the index of the answers is different, but in the database they are tied to the question.
Array
(
[0] => What is the clipboard?
[169] => Memory area
[170] => Special folder in the file system
[171] => Special file
[172] => Magnetic media
)
Array
(
[0] => What are the parts of a Windows file designation?
[177] => three parts: name, extension, and domain name
[178] => two parts: name and domain name
[179] => two parts: name and extension
[180] => from one part: name
)
Is it possible to do shuffle(); to shuffle the answers in places without touching index 0?
Answer the question
In order to leave comments, you need to log in
You can't, but you can store data in a normal structure and then shuffle can be run without any problems.
$questions = [
[
'id' => 42,
'text' => 'Что такое буфер обмена?',
'answers' => [
['id' => 169, 'text' => 'Область в памяти'],
['id' => 170, 'text' => 'Специальная папка в файловой системе'],
['id' => 171, 'text' => 'Специальный файл'],
['id' => 172, 'text' => 'Магнитный носитель'],
],
],
]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question