我试图首先对数组进行排序,然后按字母顺序显示它
$testArray[test] = 'London';
$testArray[fsee] = 'Cardiff';
$testArray[pol] = 'Edinburgh';
$testArray[bede] = 'Manchester';
asort($testArray);
foreach ($testArray as $key => $value) {
echo $key . ' -- ' . $value . '<br/>';
}
我喜欢按字母顺序对 test、fsee、pol 和 bede 进行排序,所以它返回
bede -- Manchester
fsee -- Cardiff
pol -- Edinburgh
test -- London
使用ksort
功能。
ksort($testArray);
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句