0

Here's my array

Array
(
    [_id] => MongoId Object
        (
            [$id] => 4ff6e96bb0b4599016000006
        )

    [alias] => me
    [create] => 1341581675
    [name] => It's Me!
)

I set [id] => 4ff6e96bb0b4599016000006 and unset [_id]

Now

Array
(
    [alias] => me
    [create] => 1341581675
    [name] => It's Me!
    [id] => 4ff6e96bb0b4599016000006 
)

What's the best way to order [id] on top and order [create] after [name]

Thanks

1 Answers1

0

Instead of setting $yourArray['id'] = '4ff6e9...0006', you could (ab)use array_merge() to add it:

$yourArray = array_merge(array('id'=>'4ff6e9...006'), $yourArray);

This should basically append your original array to the small array above which contains only the key 'id'.

Floern
  • 33,559
  • 24
  • 104
  • 119