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


PHP MergeArrays函數代碼示例

本文整理匯總了PHP中MergeArrays函數的典型用法代碼示例。如果您正苦於以下問題:PHP MergeArrays函數的具體用法?PHP MergeArrays怎麽用?PHP MergeArrays使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


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

示例1: MergeArrays

function MergeArrays($Arr1, $Arr2)
{
    foreach ($Arr2 as $key => $Value) {
        if (array_key_exists($key, $Arr1) && is_array($Value) && is_array($Arr1[$key])) {
            $Arr1[$key] = MergeArrays($Arr1[$key], $Arr2[$key]);
        } else {
            $Arr1[$key] = $Value;
        }
    }
    return $Arr1;
}
開發者ID:niieani,項目名稱:napkin,代碼行數:11,代碼來源:arrMerge.php

示例2: MergeArrays

 /**
  * Merge two associative arrays into a single array.
  *
  * @param array The "dominant" array, who's values will be chosen over those of the subservient.
  * @param array The "subservient" array, who's values will be disregarded over those of the dominant.
  */
 function MergeArrays(&$Dominant, $Subservient)
 {
     foreach ($Subservient as $Key => $Value) {
         if (!array_key_exists($Key, $Dominant)) {
             // Add the key from the subservient array if it doesn't exist in the
             // dominant array.
             $Dominant[$Key] = $Value;
         } else {
             // If the key already exists in the dominant array, only continue if
             // both values are also arrays - because we don't want to overwrite
             // values in the dominant array with ones from the subservient array.
             if (is_array($Dominant[$Key]) && is_array($Value)) {
                 $Dominant[$Key] = MergeArrays($Dominant[$Key], $Value);
             }
         }
     }
     return $Dominant;
 }
開發者ID:remobjects,項目名稱:Garden,代碼行數:24,代碼來源:functions.general.php

示例3: assignStatsVal

/**
 * Assign the statistics values of a data center to the overall statistics
 *  $dcStats
 *
 * @param array $dcStats
 * @param DataCenter $dc
 * @param array $Stats
 */
function assignStatsVal(&$dcStats, $dc, $Stats)
{
    $arr = array();
    $tmp =& $arr;
    $dcContainerList = $dc->getContainerList();
    $dcContainerList[] = $dc->Name;
    foreach ($dcContainerList as $level) {
        $tmp[$level] = array();
        $tmp =& $tmp[$level];
    }
    $tmp = $Stats;
    //   $dcStats = array_merge_recursive($dcStats, $arr);
    $dcStats = MergeArrays($dcStats, $arr);
}
開發者ID:dc-admin,項目名稱:openDCIM,代碼行數:22,代碼來源:report_asset_Excel-new.php

示例4: Save

 /**
  * Takes a set of form data ($Form->_PostValues), validates them, and
  * inserts or updates them to the configuration file.
  *
  * @param array $FormPostValues An associative array of $Field => $Value pairs that represent data posted
  * from the form in the $_POST or $_GET collection.
  */
 public function Save($FormPostValues)
 {
     // Fudge your way through the schema application. This will allow me to
     // force the validation object to expect the fieldnames contained in
     // $this->Data.
     $this->Validation->ApplySchema($this->Data);
     // Validate the form posted values
     if ($this->Validation->Validate($FormPostValues)) {
         // Merge the validation fields and the forced settings into a single array
         $Settings = $this->Validation->ValidationFields();
         if (is_array($this->_ForceSettings)) {
             $Settings = MergeArrays($Settings, $this->_ForceSettings);
         }
         return SaveToConfig($Settings);
     } else {
         return FALSE;
     }
 }
開發者ID:Aetasiric,項目名稱:Garden,代碼行數:25,代碼來源:class.configurationmodel.php

示例5: Save

 /**
  * Takes a set of form data ($Form->_PostValues), validates them, and
  * inserts or updates them to the configuration file.
  *
  * @param array $FormPostValues An associative array of $Field => $Value pairs that represent data posted
  * from the form in the $_POST or $_GET collection.
  */
 public function Save($FormPostValues, $Live = FALSE)
 {
     // Fudge your way through the schema application. This will allow me to
     // force the validation object to expect the fieldnames contained in
     // $this->Data.
     $this->Validation->ApplySchema($this->Data);
     // Validate the form posted values
     if ($this->Validation->Validate($FormPostValues)) {
         // Merge the validation fields and the forced settings into a single array
         $Settings = $this->Validation->ValidationFields();
         if (is_array($this->_ForceSettings)) {
             $Settings = MergeArrays($Settings, $this->_ForceSettings);
         }
         $SaveResults = SaveToConfig($Settings);
         // If the Live flag is true, set these in memory too
         if ($SaveResults && $Live) {
             Gdn::Config()->Set($Settings, TRUE);
         }
         return $SaveResults;
     } else {
         return FALSE;
     }
 }
開發者ID:tautomers,項目名稱:knoopvszombies,代碼行數:30,代碼來源:class.configurationmodel.php

示例6: Save

 /**
  * Takes a set of form data ($Form->_PostValues), validates them, and
  * inserts or updates them to the configuration file.
  *
  * @param array $FormPostValues An associative array of $Field => $Value pairs that represent data posted
  * from the form in the $_POST or $_GET collection.
  */
 public function Save($FormPostValues)
 {
     if (isset($this->_ConfigurationFile) === FALSE) {
         trigger_error(ErrorMessage('You must define the file where the configuration settings will be saved.', 'ConfigurationModel', 'Save'), E_USER_ERROR);
     }
     // Fudge your way through the schema application. This will allow me to
     // force the validation object to expect the fieldnames contained in
     // $this->Data.
     $this->Validation->ApplySchema($this->Data);
     // Validate the form posted values
     if ($this->Validation->Validate($FormPostValues)) {
         $Config = Gdn::Factory(Gdn::AliasConfig);
         $Config->Load($this->_ConfigurationFile, 'Save', $this->Name);
         // Merge the validation fields and the forced settings into a single array
         $Settings = $this->Validation->ValidationFields();
         if (is_array($this->_ForceSettings)) {
             $Settings = MergeArrays($Settings, $this->_ForceSettings);
         }
         foreach ($Settings as $Setting => $Value) {
             $Config->Set($Setting, $Value, TRUE);
         }
         // And save them to the conf file
         return $Config->Save();
     } else {
         return FALSE;
     }
 }
開發者ID:kidmax,項目名稱:Garden,代碼行數:34,代碼來源:class.configurationmodel.php


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