如何将PHP数组项放到最后一个位置?
我想把数组的某些元素放在最后一个位置,当我循环并将$ arr输出到html时,这将保持“其他”项目始终在最后。有什么最好且简单的方法来做到这一点吗?
<?php
$arr=array(
'a'=>'hello',
'game'=>'boy',
'other'=>'good',
'name'=>'jimmy',
//...
);
// how to resort $arr to put other item to then end of $arr
$arr=array(
'a'=>'hello',
'game'=>'boy',
'name'=>'jimmy',
//...
'other'=>'good'
);
?>
array_slice()
无法根据键值进行搜索。 - Ja͢ck