0

我需要循环这个值

$blocks = array();

$blocks['list_modules']

有了这个:

$form['advanced']['custom_acc'] = array(
    '#type' => 'select',
    '#title' => t('module title'),
    '#options' => array(
      0 => t('No control'),
      1 => t('Controlled'),
      ),
  );

所以它应该变成这样

        while (list(, $value) = each($blocks)) {
        echo "

    $form['advanced']['custom_->blocks array value'] = array(
        '#type' => 'select',
        '#title' => t('->blocks array value'),
        '#options' => array(
          0 => t('No control'),
          1 => t('Controlled'),
          ),
      );
  ";
}

但这当然行不通,有什么想法吗?我想我必须使用 foreach,我希望你能看到我想要实现的目标,

提前致谢!

4

1 回答 1

0

自己修好了:)

    $blocks = array();
$blocks = module_list();

foreach ($blocks as $key => $title) {

$form['advanced'][$title] = array(
    '#type' => 'select',
    '#title' => t($title),
    '#options' => array(
      0 => t('No control'),
      1 => t('Controlled'),
      ),
  );
}
于 2012-06-29T08:09:20.220 回答