Let's say there are 2 arrays of $ A and $b
$a =array ("1" = "123", "2" = "1234", "3" and "1334");
$b =array ("1" = "123", "2" = "1230");
How to Get $c=array ("2" = "12234", "3" = "delete");
Because 1 corresponds to 123 is the same minus 2 corresponding because $b is smaller than a $ A, so to keep $ A 3 because it does not exist, so the back becomes "delete"
Reply to discussion (solution)
$a = Array ("1" = "123", "2" = "1234", "3" = "1334"), $b = Array ("1" = "123", "2" = "1230"); $c = Array (); foreach ($a as $k = + $v) { if (isset ($b [$k])) { if ($b [$k] = = $v) continue;//the same does not save $c [$k] = max ($b [$k], $v); /not identical to keep large }else $c [$k] = ' delete ';} Print_r ($c);
Array
(
[2] = 1234
[3] = = Delete
)
$a = Array ("1" = "123", "2" = "1234", "3" = "1334"), $b = Array ("1" = "123", "2" = "1230"); $c = Array (); foreach ($a as $key = + $val) {if (Isset ($b [$key])) {if ($val! = $b [$key]) {$c [$key] = $val > $b [$key]? $val: $b [$key];}} else{$c [$key] = ' delete ';}} Print_r ($c);