目标是提取最小、中间和最远距离。成功达到了最低距离。然而,中间和最高距离更复杂。
数组内容如下所示: 数组名:$array
Array
(
[0] => Array
(
[city] => Array
(
[0] => Reduit
[1] => Curepipe
)
[distance] => 200
)
[1] => Array
(
[city] => Array
(
[0] => Array
(
[0] => Reduit
[1] => Ebe
)
[1] => Bees Village
[2] => Phoen Trunk Rd
[3] => Riv,Phoenix
[4] => St l Rd
[5] => Geoes Guibert St
[6] => Curepipe
)
[distance] => 151
)
[2] => Array
(
[city] => Array
(
[0] => Array
(
[0] => Reduit
[1] => Riv,Phoenix
)
[1] => St l Rd
[2] => Geoes Guibert St
[3] => Curepipe
)
[distance] =>50
)
[3] => Array
(
[city] => Array
(
[0] => Array
(
[0] => Reduit
[1] => Ebene
)
[1] => Belles Village
[2] => Phoenix Trunk Rd
[3] => Riverside,Phoenix
[4] => St Paul Rd
[5] => Georges Guibert St
[6] => Curepipe
)
[distance] => 101
)
)
谁能告诉我哪里错了。我的工作是
$current = $array[0]['distance'];
for($middleDistance=1;$middleDistance<$total;$middleDistance++){
$next = $array[($middleDistance)]['distance'];
if ($next<$current){
$current = $next;
print_r($current);
if($current>50&&$current<100){
}
}
}