本文整理汇总了PHP中CMbArray::mergeRecursive方法的典型用法代码示例。如果您正苦于以下问题:PHP CMbArray::mergeRecursive方法的具体用法?PHP CMbArray::mergeRecursive怎么用?PHP CMbArray::mergeRecursive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CMbArray
的用法示例。
在下文中一共展示了CMbArray::mergeRecursive方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testMergeRecursive
public function testMergeRecursive()
{
$this->assertNull($this->stub->mergeRecursive(null, null));
$this->assertNull($this->stub->mergeRecursive(array(1), null));
$array1 = array(0 => "val1");
$array2 = array(1 => "val2");
$this->assertNotEmpty($this->stub->mergeRecursive($array1, $array2));
$this->assertEquals(array(0 => "val1", 1 => "val2"), $this->stub->mergeRecursive($array1, $array2));
$array1 = array(0 => "val1");
$array2 = array(1 => "val2", array(2 => "val3", array(3 => "val4")));
$resArray = array(0 => "val1", 1 => "val2", array(2 => "val3", array(3 => "val4")));
$this->assertEquals($resArray, $this->stub->mergeRecursive($array1, $array2));
}
示例2: update
function update($newValues = array(), $keepOld = true)
{
$newValues = array_map_recursive('stripslashes', $newValues);
if ($keepOld) {
$this->load();
$newValues = CMbArray::mergeRecursive($this->values, $newValues);
}
if (!count($newValues)) {
if (is_file($this->targetPath)) {
unlink($this->targetPath);
}
return;
}
$this->values = $newValues;
// Throws many E_STRICT errors
$config = @new Config();
@$config->parseConfig($this->values, $this->configType, $this->options);
return @$config->writeConfig($this->targetPath, $this->configType, $this->options);
}
示例3: mergeRecursive
/**
* Merge recursively two array
*
* @param array $paArray1 First array
* @param array $paArray2 The array to be merged
*
* @return array The merge result
*/
static function mergeRecursive($paArray1, $paArray2)
{
if (!is_array($paArray1) || !is_array($paArray2)) {
return $paArray2;
}
foreach ($paArray2 as $sKey2 => $sValue2) {
$paArray1[$sKey2] = CMbArray::mergeRecursive(@$paArray1[$sKey2], $sValue2);
}
return $paArray1;
}