0

I have array as result from postgres database and i want to sort in order defined by data like this:

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

array:

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

to array:

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

somehow to sort array in order by $order array IDs.

Next Example: $order = array(77082, 65666, 90555, 35000);

array:

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

to array:

array(
    array("id" => 77082, "title" => "Test"),
    array("id" => 65666, "title" => "Test1")
    array("id" => 90555, "title" => "Test2")
    array("id" => 35000, "title" => "Test3")
);
Emrah Mehmedov
  • 1,492
  • 13
  • 28

0 Answers0