本文整理汇总了PHP中CArrayHelper::renameKeys方法的典型用法代码示例。如果您正苦于以下问题:PHP CArrayHelper::renameKeys方法的具体用法?PHP CArrayHelper::renameKeys怎么用?PHP CArrayHelper::renameKeys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CArrayHelper
的用法示例。
在下文中一共展示了CArrayHelper::renameKeys方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renameGraphFields
/**
* Rename graphs, graph prototypes fields.
*
* @param array $graph
*
* @return array
*/
protected function renameGraphFields(array $graph)
{
return CArrayHelper::renameKeys($graph, ['type' => 'graphtype', 'ymin_type_1' => 'ymin_type', 'ymax_type_1' => 'ymax_type', 'graph_items' => 'gitems']);
}
示例2: convertScreens
/**
* Convert screen elements.
*
* @param array $content
*
* @return array
*/
protected function convertScreens(array $content)
{
if (!isset($content['screens']) || !$content['screens']) {
return $content;
}
foreach ($content['screens'] as &$screen) {
$screen = CArrayHelper::renameKeys($screen, ['screenitems' => 'screen_items']);
if (isset($screen['screen_items']) && $screen['screen_items']) {
foreach ($screen['screen_items'] as &$screenItem) {
$screenItem = CArrayHelper::renameKeys($screenItem, ['resourceid' => 'resource']);
if (isset($screenItem['resource']) && $screenItem['resource'] !== '0') {
$screenItem['resource'] = CArrayHelper::renameKeys($screenItem['resource'], ['key_' => 'key']);
}
}
unset($screenItem);
}
}
unset($screen);
return $content;
}