當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CArrayHelper::getByKeys方法代碼示例

本文整理匯總了PHP中CArrayHelper::getByKeys方法的典型用法代碼示例。如果您正苦於以下問題:PHP CArrayHelper::getByKeys方法的具體用法?PHP CArrayHelper::getByKeys怎麽用?PHP CArrayHelper::getByKeys使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CArrayHelper的用法示例。


在下文中一共展示了CArrayHelper::getByKeys方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getHosts

 public function getHosts()
 {
     $hostsData = array();
     if (!empty($this->data['hosts'])) {
         foreach ($this->data['hosts'] as $host) {
             $host = $this->renameData($host, array('proxyid' => 'proxy_hostid'));
             CArrayHelper::convertFieldToArray($host, 'interfaces');
             if (!empty($host['interfaces'])) {
                 foreach ($host['interfaces'] as $inum => $interface) {
                     $host['interfaces'][$inum] = $this->renameData($interface, array('default' => 'main'));
                 }
             }
             CArrayHelper::convertFieldToArray($host, 'templates');
             if (empty($host['templates'])) {
                 unset($host['templates']);
             }
             CArrayHelper::convertFieldToArray($host, 'macros');
             CArrayHelper::convertFieldToArray($host, 'groups');
             if (!empty($host['inventory']) && isset($host['inventory']['inventory_mode'])) {
                 $host['inventory_mode'] = $host['inventory']['inventory_mode'];
                 unset($host['inventory']['inventory_mode']);
             } else {
                 $host['inventory_mode'] = HOST_INVENTORY_DISABLED;
             }
             $hostsData[] = CArrayHelper::getByKeys($host, array('inventory', 'proxy', 'groups', 'templates', 'macros', 'interfaces', 'host', 'status', 'ipmi_authtype', 'ipmi_privilege', 'ipmi_username', 'ipmi_password', 'name', 'inventory_mode'));
         }
     }
     return $hostsData;
 }
開發者ID:itnihao,項目名稱:zatree-2.2,代碼行數:29,代碼來源:C20ImportFormatter.php

示例2: getHosts

 /**
  * Get hosts from the imported data.
  *
  * @return array
  */
 public function getHosts()
 {
     $hosts = [];
     if (array_key_exists('hosts', $this->data)) {
         foreach ($this->data['hosts'] as $host) {
             $host = CArrayHelper::renameKeys($host, ['proxyid' => 'proxy_hostid']);
             if (array_key_exists('interfaces', $host)) {
                 foreach ($host['interfaces'] as $inum => $interface) {
                     $host['interfaces'][$inum] = CArrayHelper::renameKeys($interface, ['default' => 'main']);
                 }
             }
             if (array_key_exists('inventory', $host)) {
                 if (array_key_exists('inventory_mode', $host['inventory'])) {
                     $host['inventory_mode'] = $host['inventory']['inventory_mode'];
                     unset($host['inventory']['inventory_mode']);
                 } else {
                     $host['inventory_mode'] = HOST_INVENTORY_DISABLED;
                 }
             }
             $hosts[] = CArrayHelper::getByKeys($host, ['inventory', 'proxy', 'groups', 'templates', 'macros', 'interfaces', 'host', 'status', 'description', 'ipmi_authtype', 'ipmi_privilege', 'ipmi_username', 'ipmi_password', 'name', 'inventory_mode', 'tls_connect', 'tls_accept', 'tls_issuer', 'tls_subject', 'tls_psk_identity', 'tls_psk']);
         }
     }
     return $hosts;
 }
開發者ID:jbfavre,項目名稱:debian-zabbix,代碼行數:29,代碼來源:CImportDataAdapter.php


注:本文中的CArrayHelper::getByKeys方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。