string(2) "24" ["FromMid"] => string(3) "157" ["ToMid"] => s">
时间:2021-07-01 10:21:17 帮助过:3人阅读
------解决方案--------------------
$data = array( array("Id" => "24", "FromMid" => "157", "ToMid" => "157"), array("Id" => "22", "FromMid" => "157", "ToMid" => "176"), array("Id" => "4", "FromMid" => "157", "ToMid" => "25"), array("Id" => "1", "FromMid" => "25", "ToMid" => "157") ); $markList = array(); foreach ($data as $key => $val) { $posi = md5($val['FromMid'] . $val['ToMid']); $anti = md5($val['ToMid'] . $val['FromMid']); if (isset($markList[$posi]) || isset($markList[$anti])) { unset($data[$key]); } else { $markList[$posi] = $markList[$anti] = 1; } } echo '';print_r($data); /**输出: Array ( [0] => Array ( [Id] => 24 [FromMid] => 157 [ToMid] => 157 ) [1] => Array ( [Id] => 22 [FromMid] => 157 [ToMid] => 176 ) [2] => Array ( [Id] => 4 [FromMid] => 157 [ToMid] => 25 ) */