如何删除重复距离值的数组?
Array([0] => Array([distance] => 66.68 [lat] => 51.8560591 [long] => -2.2170209 [ordNum] => 1/5938ebf2475fa ))
Array([0] => Array([distance] => 66.68 [lat] => 51.8560591 [long] => -2.2170209 [ordNum] => 1/5938e93c2080e ))
Array([0] => Array([distance] => 123.93 [lat] => 51.8560591 [long] => -2.2170209 [ordNum] => 1/5938ebf2475fa))
Array([0] => Array([distance] => 123.93 [lat] => 51.8560591 [long] => -2.2170209 [ordNum] => 1/5938e93c2080e))
Array([0] => Array([distance] => 128.84 [lat] => 52.6301043 [long] => -2.4940598 [ordNum] => 1/5938e979bdb8b))
Array([0] => Array([distance] => 148.43 [lat] => 52.6301043 [long] => -2.4940598 [ordNum] => 1/5938e979bdb8b))
答案 0 :(得分:0)
首先,您必须制作多维数组而不是不同数组
**Do as mentioned as below.**
$data = "Array
(
[0] => Array
(
[distance] => 66.68
[lat] => 51.8560591
[long] => -2.2170209
[ordNum] => 1/5938ebf2475fa
)
[1] => Array
(
[distance] => 66.68
[lat] => 51.8560591
[long] => -2.2170209
[ordNum] => 1/5938e93c2080e
)
[2] => Array
(
[distance] => 123.93
[lat] => 51.8560591
[long] => -2.2170209
[ordNum] => 1/5938ebf2475fa
)
[3] => Array
(
[distance] => 123.93
[lat] => 51.8560591
[long] => -2.2170209
[ordNum] => 1/5938e93c2080e
)
)";
echo '<pre/>';
$data1 = array( array('distance' => '123.93','lat' => '51.8560591','long' => '-2.2170209','ordNum' => '1/5938e93c2080e'),
array('distance' => '123.93','lat' => '51.8560591','long' => '-2.2170209','ordNum' => '1/5938ebf2475fa'),
array('distance' => '66.68','lat' => '51.8560591','long' => '-2.2170209','ordNum' => '1/5938e93c2080e'),
array('distance' => '66.68','lat' => '51.8560591','long' => '-2.2170209','ordNum' => '1/5938ebf2475fa'));
$newArr = array();
foreach ($data1 as $val) {
$newArr[$val['distance']] = $val;
}
$array = array_values($newArr);
print_r($array);