douhuang75397
2013-09-06 15:54
采纳率: 0%
浏览 38
已采纳

PHP - array_multisort? 邮政编码排序(邮政编码)

After calculating distances between two points using latitude and longitude, I've created an array which looks like this:

$enterprises = array();

//Ex.: Array ( [0] => Array ( [A0A0A0] => 0 ) [1] => Array ( [A0A1A0] => 22.794344863539 ) 
for ($i=0; $i < count($cpEnterprise) ; $i++) {

        $enterprises[] = array($cpEnterprise[$i] => distance($actualCpLat, $actualCpLong, $businessLat[$i], $businessLong[$i], 'k'));

}

The main array contains the enterprises that is needed for a comparison with the actual postal codes inside it. POSTAL CODE => DISTANCE.

I need to sort those inner arrays by distance from the nearest to the farthest and I don't really understand how array_multisort works...

图片转代码服务由CSDN问答提供 功能建议

使用纬度和经度计算两点之间的距离后,我创建了一个如下所示的数组:</ p>

  $ enterprises = array(); 
 
 // Ex。:Array([0] =&gt;数组([A0A0A0] =&gt; 0)[1] =  &gt;数组([A0A1A0] =&gt; 22.794344863539)
for($ i = 0; $ i&lt; count($ cpEnterprise); $ i ++){
 
 $ enterprises [] = array($ cpEnterprise [$ i  ] =&gt;距离($ actualCpLat,$ actualCpLong,$ businessLat [$ i],$ businessLong [$ i],'k')); 
 
} 
 </ code> </ pre> 
 \  n 

主数组包含与其中的实际邮政编码进行比较所需的企业.POSTAL CODE =&gt; DISTANCE。</ p>

我需要按以下方式对这些内部数组进行排序 从最近到最远的距离,我真的不明白array_multisort是如何工作的...... </ p> </ div>

2条回答 默认 最新

相关推荐 更多相似问题