AndyB
Well-known member
I have an array called $threadIds.
The values are thread_id's.
I would like to create an object using the finder system and keep the same order as the $threadIds array. I realize I can add a ->order to the finder, but I would like the order in which the array is in.
This example works but the $similarThreads object is not in the same order as $threadIds array.
How can I create a $similarThreads object which will have the same order as the $threadIds array?
Thank you.
PHP:
Array
(
[0] => 271
[1] => 166
[2] => 169
[3] => 140
[4] => 367
[5] => 566
[6] => 120
)
The values are thread_id's.
I would like to create an object using the finder system and keep the same order as the $threadIds array. I realize I can add a ->order to the finder, but I would like the order in which the array is in.
This example works but the $similarThreads object is not in the same order as $threadIds array.
PHP:
foreach ($threadIds AS $threadId)
{
$conditions[] = ['thread_id', $threadId];
}
$finder = \XF::finder('XF:Thread');
$similarThreads = $finder
->whereOr($conditions)
->fetch();
How can I create a $similarThreads object which will have the same order as the $threadIds array?
Thank you.