Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法在不手动构建数组的情况下获得完整的国家列表
$options = array( '', => 'Please select your country.', 'USA' => 'USA', 'UK' => 'UK', );
有没有办法把所有国家的数组都填满?手动填充这个有点无聊
Drupal 核心存储了所有国家/地区/代码的列表,准备得当,因此您可以将其直接放入表单元素中:
require_once DRUPAL_ROOT . '/includes/locale.inc'; $options = country_get_list();