two php arrays - sort one array with the value order of another
- by Tisch
Hi there,
I have two PHP arrays like so:
Array of X records containing the ID
of Wordpress posts (in a particular
order)
Array of Wordpress posts
The two arrays look something like this:
Array One (Sorted Custom Array of Wordpress Post IDs)
Array (
[0] => 54
[1] => 10
[2] => 4
)
Array Two (Wordpress Post Array)
Array (
[0] => stdClass Object
(
[ID] => 4
[post_author] => 1
)
[1] => stdClass Object
(
[ID] => 54
[post_author] => 1
)
[2] => stdClass Object
(
[ID] => 10
[post_author] => 1
)
)
I would like to sort the array of wordpress posts with the order of the ID's in the first array.
I hope this makes sense, and thanks in advance of any help.
Tom
edit: The server is running PHP Version 5.2.14