我正在尝试执行某种函数来查找(在以下数组中)id 为 2 的对象,并将其移动到数组的顶部。这是原始数组:
Array
(
[0] => stdClass Object
(
[id] => 177
[startdate] => 2014-08-02
)
[1] => stdClass Object
(
[id] => 178
[startdate] => 2014-08-02
)
[2] => stdClass Object
(
[id] => 2
[startdate] => 2014-07-28
)
[3] => stdClass Object
(
[id] => 82
[startdate] => 2014-07-28
)
[4] => stdClass Object
(
[id] => 199
[startdate] => 2013-10-10
)
)
这是我希望它输出的内容(使用移动的数组项):
Array
(
[0] => stdClass Object
(
[id] => 2
[startdate] => 2014-07-28
)
[1] => stdClass Object
(
[id] => 177
[startdate] => 2014-08-02
)
[2] => stdClass Object
(
[id] => 178
[startdate] => 2014-08-02
)
[3] => stdClass Object
(
[id] => 82
[startdate] => 2014-07-28
)
[4] => stdClass Object
(
[id] => 199
[startdate] => 2013-10-10
)
)
任何帮助,将不胜感激。