function swftools_array_merge in SWF Tools 6.3
Merges two multi-dimensional arrays.
This function is used by players that filter their settings to strip out blanks or defaults. For the admin page we need a full set of values to prevent errors. Since the arrays might be multi-dimensional we cannot use a regular array_merge(). The values in the first array will be over-written by values in the second, if they exist.
Parameters
array $array1: The first array to merge.
array $array2: The second array to merge.
Return value
array The result of the merge.
4 calls to swftools_array_merge()
- _swftools_flexpaper_settings in flexpaper/
swftools_flexpaper.module - Returns the player default settings, or customised settings from the configuration page.
- _swftools_imagerotator_settings in imagerotator/
swftools_imagerotator.module - These are the default settings as they are stored in the database and displayed on the settings page.
- _swftools_jw5_settings in jw5/
swftools_jw5.module - Returns an array of default settings for the JW Player
- _swftools_wijering4_settings in wijering4/
swftools_wijering4.module - Returns an array of default settings for the JW Player
File
- ./
swftools.module, line 1831 - The primary component of SWF Tools that enables comprehensive media handling.
Code
function swftools_array_merge($array1, $array2) {
// Iterate over $array 2 (this is normally the smaller of the two)
foreach ($array2 as $key => $value) {
// If this key is present in $array1 then work out what to do
if (isset($array1[$key])) {
// If both keys hold arrays, combine them
if (is_array($value) && is_array($array1[$key])) {
$array1[$key] = swftools_array_merge($array1[$key], $value);
}
else {
// Replace value in $array1 with that from $array2
$array1[$key] = $value;
}
}
else {
// Simply put this value in $array1 if it isn't already in $array1
$array1[$key] = $value;
}
}
// Return the result
return $array1;
}