我目前有一个存储大量问题,问题类型和答案的数组。现在答案可以有不同的长度。例如:如何将数组键与特定的先前键相关联?
0 => array:222 [▼
0 => "(Type): multiplechoice"
1 => "(Question): Which of the following is true about pre-test imagery?"
2 => "(A): People with a cranial fault can visualize the muscle being strong and make it go strong, while people without a cranial faults cannot."
3 => "(B): If Governing Vessel (GV) 20 tests weak, it also means they have a cranial fault. This is on the midline at the apex of the head."
4 => "(C): The three most common cranial faults are TMJ, occiput and sphenoid"
5 => "(D): All of the above"
6 => "(Correct): D"
7 => "(Type): multiplechoice"
8 => "(Question): Which of the following is not true about the TMJ?"
9 => "(A): Every single TMJ nerve pathway goes through the mesencephalon in the midbrain."
10 => "(B): When you work on the TMJ it is a neurological back-up for the entire body."
11 => "(C): To correct press on the glabella with one hand as you press of the back of the head with the other as the patient touches the chin with two fingers and breathes in only one time."
12 => "(Correct): C"
13 => "(Type): truefalse"
14 => "(Question): To test for a deficiency of the four primary neurotransmitters, point the edge of a magnet straight in at each of the four corresponding cranial bon ▶"
15 => "(A): True"
16 => "(B): False"
17 => "(Correct): A"
我所面临的问题是,每一个问题包括question
,type
和correct
价值,但可能有不同数量的答案 - 10+答案是可能的。
我目前的做法是通过数组工作并为问题,类型和更正创建新的数组,然后循环访问数组并通过键对pair问题的值。由于事实上存在不同数量的答案,所以这不幸没有结束。
这可能是一种可能的方法?我怎样才能将所有的价值观与适当的问题联系起来?
非常感谢您的帮助和提示!
为什么钥匙36位于钥匙12和13之间? – Andreas
发布预期结果 – RomanPerekhrest
@mickmackusa拥有222项内容并不是问题。但确定第一个正则表达式可以用strpos或者substr来替换。无论哪种方式,我怀疑它会在现实生活中有很大的变化。 – Andreas