我有一个$ _POST数组,我想重新格式化处理。 $ _POST的转储如下所示:
Array
(
[question_0] => Why Wordpress is the best
[question_0_answer_0] => First Choice
[question_0_answer_1] => Second Choice
[correct0] => question_0_answer_3
[question_0_answer_3] => adrian stinks
[question_1] => Who do you love?
[question_1_answer_0] => First Choice
[question_1_answer_1] => Second Choice
[question_1_answer_2] => Third Choice
[question_2] => What is your name?
[question_2_answer_0] => First Choice
[question_2_answer_1] => Second Choice
[question_2_answer_2] => Third Choice
[quiz_id] => 17
[submit] => Save Quiz
)
我想整理并获得一个看起来像这样的排序数组:
$fields=array(
array(
type=>radio,
text=>Why wordpress is the best
choices=>array(
array(
text=>First Choice,
value=>First Choice,
is_correct=>FALSE
),
array(
text=>First Choice,
value=>First Choice,
is_correct=>FALSE
),
array(
text=>Adrian Stinks,
value=>Adrian Stinkse,
is_correct=>TRUE
)
)
),
array(
type=>page //divider
),
array(
type=>radio,
text=>Who do you love?
choices=>array(
array(
text=>First Choice,
value=>First Choice,
is_correct=>TRUE
),
array(
text=>First Choice,
value=>First Choice,
is_correct=>TRUE
),
array(
text=>Third Choice,
value=>Third Choice,
is_correct=>FALSE
)
)
),
array(
type=>page //divider
),
array(
type=>radio,
text=>What is your name?
choices=>array(
array(
text=>First Choice,
value=>First Choice,
is_correct=>TRUE
),
array(
text=>First Choice,
value=>First Choice,
is_correct=>TRUE
),
array(
text=>Third Choice,
value=>Third Choice,
is_correct=>FALSE
)
)
),
)
我如何实现这种排序?提前谢谢!