日期:2014-05-17 浏览次数:20532 次
<?php $input = array("red", "green", "blue", "yellow"); array_splice($input, 2); // $input is now array("red", "green") $input = array("red", "green", "blue", "yellow"); array_splice($input, 1, -1); // $input is now array("red", "yellow") $input = array("red", "green", "blue", "yellow"); array_splice($input, 1, count($input), "orange"); // $input is now array("red", "orange") $input = array("red", "green", "blue", "yellow"); array_splice($input, -1, 1, array("black", "maroon")); // $input is now array("red", "green", // "blue", "black", "maroon") $input = array("red", "green", "blue", "yellow"); array_splice($input, 3, 0, "purple"); // $input is now array("red", "green", // "blue", "purple", "yellow"); ?>
------解决方案--------------------
$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])