1
0
Fork 0
mirror of https://github.com/Oreolek/ifhub.club.git synced 2024-06-26 11:40:48 +03:00

fix - added definition of the functions array_fill_keys and array_intersect_key if they do not exist in the current version of PHP

This commit is contained in:
Mzhelskiy Maxim 2010-01-08 09:31:00 +00:00
parent 49054850df
commit 91588cbb9e

View file

@ -366,4 +366,41 @@ function func_array_merge_assoc($aArr1,$aArr2) {
return $aRes;
}
if (!function_exists('array_fill_keys')) {
function array_fill_keys($aArr, $values) {
if (!is_array($aArr)) {
$aArr=array($aArr);
}
$aArrOut=array();
foreach($aArr as $key => $value) {
$aArrOut[$value] = $values;
}
return $aArrOut;
}
}
if (!function_exists('array_intersect_key')) {
function array_intersect_key($isec, $keys) {
$argc = func_num_args();
if ($argc > 2) {
for ($i = 1; !empty($isec) && $i < $argc; $i++) {
$arr = func_get_arg($i);
foreach (array_keys($isec) as $key) {
if (!isset($arr[$key])) {
unset($isec[$key]);
}
}
}
return $isec;
} else {
$res = array();
foreach (array_keys($isec) as $key) {
if (isset($keys[$key])) {
$res[$key] = $isec[$key];
}
}
return $res;
}
}
}
?>