本文整理汇总了PHP中util::array_first_key方法的典型用法代码示例。如果您正苦于以下问题:PHP util::array_first_key方法的具体用法?PHP util::array_first_key怎么用?PHP util::array_first_key使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类util
的用法示例。
在下文中一共展示了util::array_first_key方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: menu
/**
* Output a menu..
*
*/
public function menu(Twig_Environment $env, $identifier = "")
{
global $app;
$menus = $app['config']['menu'];
if (!empty($identifier) && isset($menus[$identifier])) {
$name = strtolower($identifier);
$menu = $menus[$identifier];
} else {
$name = strtolower(util::array_first_key($menus));
$menu = util::array_first($menus);
}
foreach ($menu as $key => $item) {
$menu[$key] = $this->menu_helper($item);
if (isset($item['submenu'])) {
foreach ($item['submenu'] as $subkey => $subitem) {
$menu[$key]['submenu'][$subkey] = $this->menu_helper($subitem);
}
}
}
// echo "<pre>\n" . util::var_dump($menu, true) . "</pre>\n";
echo $env->render('_sub_menu.twig', array('name' => $name, 'menu' => $menu));
}
示例2: getTaxonomy
/**
* Get the taxonomy for one or more units of content, return the array with the taxonomy attached.
*
* @param array $content
*
* @return array $content
*/
protected function getTaxonomy($content)
{
$tablename = $this->prefix . "taxonomy";
$ids = util::array_pluck($content, 'id');
if (empty($ids)) {
return $content;
}
// Get the contenttype from first $content
$contenttype = $content[util::array_first_key($content)]->contenttype['slug'];
$taxonomytypes = array_keys($this->config['taxonomy']);
$query = sprintf("SELECT * FROM {$tablename} WHERE content_id IN (%s) AND contenttype=%s AND taxonomytype IN ('%s')", implode(", ", $ids), $this->db->quote($contenttype), implode("', '", $taxonomytypes));
$rows = $this->db->fetchAll($query);
foreach ($rows as $key => $row) {
$content[$row['content_id']]->setTaxonomy($row['taxonomytype'], $row['slug']);
}
}
示例3: test_array_first_key
public function test_array_first_key()
{
$test = array('a' => array('a' => 'b', 'c' => 'd'));
$this->assertEquals('a', util::array_first_key(util::array_get($test, 'a')));
}