<?php
$followed = Array(
0=>array(
'label' =>"label0",
'id_poste'=>1,
'id_part'=>11,
'date'=>'9/12/21012'
),
1=>array(
'label' =>"label1",
'id_poste'=>2,
'id_part'=>12,
'date'=>'10/13/21012'
)
);
$unfollowed = Array(
0=>array(
'label' =>"New label",
'id_poste'=>1,
'id_part'=>11
)
);
这样做可以合并两个数组。
$result = array_merge($followed,
array_udiff($unfollowed, $followed,
function($a,$b){
return strcmp($a['label'],$b['label']);
}
)
);
我想要result
Array
(
[0] => Array
(
[label] => label0
[id_poste] => 1
[id_part] => 11
[date] => 9/12/21012
)
[1] => Array
(
[label] => label1
[id_poste] => 2
[id_part] => 12
[date] => 10/13/21012
)
[2] => Array
(
[label] =>(A)New label /*concatenate with (A)*/
[id_poste] => 1
[id_part] => 11,
[date]=>'--/--/----' /* Append new element with that format*/
)
)
?>