Paylaş.
<?php
$dizi1 = array(“adi” => “burhan”, “soyadi” => “karadere”);
$dizi2 = array(“adi” => “BurHaN”,”id” => “250”);
function polecat_array_replace( array &$array1, array &$array2 ) {
if(!function_exists(‘tier_parse’)){
function tier_parse(array &$t_array1, array&$t_array2) {
foreach ($t_array2 as $k2 => $v2) {
if (is_array($t_array2[$k2])) {
tier_parse($t_array1[$k2], $t_array2[$k2]);
} else {
$t_array1[$k2] = $t_array2[$k2];
}
}
return $t_array1;
}
}
foreach ($array2 as $key => $val) {
if (is_array($array2[$key])) {
tier_parse($array1[$key], $array2[$key]);
} else {
$array1[$key] = $array2[$key];
}
}
return $array1;
}
print_r($dizi1);
print_r($dizi2);
polecat_array_replace($dizi1,$dizi2);
print_r($dizi1) ;
?>
VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.22_1171]
Eyl 28 2011
Php ile array ile array değiştirme. Replace array to array
Paylaş.
<?php
$dizi1 = array(“adi” => “burhan”, “soyadi” => “karadere”);
$dizi2 = array(“adi” => “BurHaN”,”id” => “250”);
function polecat_array_replace( array &$array1, array &$array2 ) {
if(!function_exists(‘tier_parse’)){
function tier_parse(array &$t_array1, array&$t_array2) {
foreach ($t_array2 as $k2 => $v2) {
if (is_array($t_array2[$k2])) {
tier_parse($t_array1[$k2], $t_array2[$k2]);
} else {
$t_array1[$k2] = $t_array2[$k2];
}
}
return $t_array1;
}
}
foreach ($array2 as $key => $val) {
if (is_array($array2[$key])) {
tier_parse($array1[$key], $array2[$key]);
} else {
$array1[$key] = $array2[$key];
}
}
return $array1;
}
print_r($dizi1);
print_r($dizi2);
polecat_array_replace($dizi1,$dizi2);
print_r($dizi1) ;
?>
By Burhan KARADERE • ? Php ? • 0 • Tags: ? Php ?, array, replace