本文整理匯總了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;
}