php循环显示3在fieldsets中

时间:2012-10-23 19:42:08

标签: php

我正在尝试将一个数组拆分为不同的字段集,每个字段集中包含3个项目

我现在有这个。但它没有吐出有效的HTML。

我这样做了吗?

function displayQuiz($TABLE_1){
shuffle($TABLE_1);
$i = 3;
$j = 1;
$split = floor(count($TABLE_1)/3);
$d = 2;
foreach ($TABLE_1 as $key => $value){
     if ($i %3 == 0) {

        echo '<fieldset id="page_'.$d.'"><ol>';
        $d++;

    }
if($i > 1){
    echo '</ol></fieldset>';
}
 if ($i == 1) {
        echo '<fieldset id="page_1"><ol>';
    }
     echo '<li>
        <h3>'.$j.'.'.$value['COL 1'].'</h3>

        <div>
            <input type="radio" name="question-'.$key.'-answers" id="question-'.$key.'-answers" value="'.$value['COL 4'].'"/>
            <label for="question-'.$key.'-answers"> '.$value['COL 2'].' </label>
        </div>
        <div>
            <input type="radio" name="question-'.$key.'-answers" id="question-'.$key.'-answers" value="'.$value['COL 5'].'"/>
            <label for="question-'.$key.'-answers"> '.$value['COL 3'].' </label>
        </div>
    </li>';

    $i++;
    $j++;
}
}

$TABLE_1 = array(  
  array('COL 1' => 'I value...','COL 2' => 'Realism and common sense','COL 3' => 'Innovation and imagination','COL 4' => 's','COL 5' => 'n'),
  array('COL 1' => 'While knowing that everyone is a unique individual deep down I feel...','COL 2' => 'Like I am basically the same as most people','COL 3' => 'Like there is something different about me compared to most people','COL 4' => 's','COL 5' => 'n'),
  array('COL 1' => 'It is better to be...','COL 2' => 'Practical','COL 3' => 'Inventive','COL 4' => 's','COL 5' => 'n'),
  array('COL 1' => 'I am drawn to...','COL 2' => 'The realistic','COL 3' => 'The surreal','COL 4' => 's','COL 5' => 'n'),
  array('COL 1' => 'I like to...','COL 2' => 'Use and refine existing skills','COL 3' => 'Pick up new skills. I can get bored once a skill is mastered','COL 4' => 's','COL 5' => 'n'),
  array('COL 1' => 'I am usually more absorbed in...','COL 2' => 'My daydreams, thoughts, and imagination','COL 3' => 'Things I can see hear feel taste or touch','COL 4' => 'n','COL 5' => 's'),
  array('COL 1' => 'I solve problems by...','COL 2' => 'Jumping between different ideas, possibilities, and perspectives','COL 3' => 'Grounding myself in the facts until I understand the problem','COL 4' => 'n','COL 5' => 's'),
  array('COL 1' => 'I think rules and regulations are...','COL 2' => 'Necessary','COL 3' => 'Necessary for other people','COL 4' => 's','COL 5' => 'n'),
  array('COL 1' => 'Regardless of what other people say, deep down I feel that I am...','COL 2' => 'Pretty normal','COL 3' => 'Kind of weird','COL 4' => 's','COL 5' => 'n'),
  array('COL 1' => 'I am usually more entertained by...','COL 2' => 'My interpretation of what is going on around me','COL 3' => 'The reality of what is going on around me','COL 4' => 'n','COL 5' => 's'),
  array('COL 1' => 'A conversation about purely abstract ideas and theories is usually...','COL 2' => 'Totally energizing','COL 3' => 'Kind of annoying','COL 4' => 'n','COL 5' => 's'),
  array('COL 1' => 'When I need to do my BEST work, the feeling of Inspiration is...','COL 2' => 'Vital, and if I do not feel inspired it is very difficult for me to produce something I am happy with','COL 3' => 'Great, but if I do not feel inspired it does not affect my ability to get things done right','COL 4' => 'n','COL 5' => 's'),
  array('COL 1' => 'Sometimes...','COL 2' => 'I think so much about new possibilities that I do not look at how to make them a reality','COL 3' => 'I pay so much attention to the facts either past or present that I miss new possibilities','COL 4' => 'n','COL 5' => 's'),
  array('COL 1' => 'In everyday life...','COL 2' => 'It is rare to meet someone that really seems to be on the same wavelength as me','COL 3' => 'I often meet people that seem to see things the way I do','COL 4' => 'n','COL 5' => 's'),
  array('COL 1' => 'Under most circumstances, I naturally pay more attention to...','COL 2' => 'What could be happening','COL 3' => 'What is happening','COL 4' => 'n','COL 5' => 's'),
  );

0 个答案:

没有答案
相关问题