*/ /** * Łączy 2 tablice, nadpisując powtarzające się klucze. * W wersji array_recursive_merge2 funkcja powielala wartosci dla kluczy liczbowych. Wersja 3 nie powtarza tych wartosci. * * @author felix dot ospald at gmx dot de * @author Marek jakubowicz $value) { if (is_array($value) && isset($ret[$key])) { // if $ret[$key] is not an array you try to merge an scalar value with an array - the result is not defined (incompatible arrays) // in this case the call will trigger an E_USER_WARNING and the $ret[$key] will be null. $ret[$key] = st_array_merge_recursive3($ret[$key], $value); } else { $ret[$key] = $value; } } } return $ret; } /** * Zwraca różnicę między 2 tablicami 1 wymiarowymi. * * @param array $dat1 * @param array $dat2 * @return array array('added'=>array(), 'changed'=>array(), 'deleted'=>array(), 'all'=>array()) */ function st_array_diff($dat1, $dat2) { $added=array();$changed=array();$deleted=array(); $all=array(); foreach ($dat2 as $key=>$val) { if (empty($dat1[$key])) { $added[]=$key; $all[]=$key; } elseif ($dat1[$key]!=$val) { $changed[]=$key; $all[]=$key; } } foreach ($dat1 as $key=>$val) { if (empty($dat2[$key])) { $deleted[]=$key; $all[]=$key; } } return array("added"=>$added,"changed"=>$changed,"deleted"=>$deleted,"all"=>$all); } ?>