php按自定义数组顺序排序数组

时间:2013-07-01 09:15:37

标签: php sorting

我有postgres数据库的结果数组,我想按照这样的数据排序:

$order = array(77082, 77083, 77084, 77085, 77086, 77087, 77088, 77089, 77090, 77091, 77092, 77093, 77094, 77095, 77096, 77097, 77098, 77099, 77100, 77101);

数组:

array(
    array("id" => 77083, "title" => "Test"),
    array("id" => 77081, "title" => "Test") ...
);

到数组:

array(
    array("id" => 77081, "title" => "Test"),
    array("id" => 77083, "title" => "Test") ...
);

以某种方式按$ order数组ID排序数组。

下一个例子: $ order = array(77082,65666,90555,35000);

数组:

array(
    array("id" => 35000, "title" => "Test3"),
    array("id" => 65666, "title" => "Test1")
    array("id" => 77082, "title" => "Test")
    array("id" => 90555, "title" => "Test2")
);

到数组:

array(
    array("id" => 77082, "title" => "Test"),
    array("id" => 65666, "title" => "Test1")
    array("id" => 90555, "title" => "Test2")
    array("id" => 35000, "title" => "Test3")
);

0 个答案:

没有答案