PHP按键重新排列数组

I have the following array...

Array (
    ["advertisers"] => Array (
        ...,
        ...,
        ...
    ),
    ["general"] => Array (
        ...,
        ...,
        ...
    ),
    ["publishers"] => Array (
        ...,
        ...,
        ...
    )
)

I would like to rearrange the array so that "advertisers" comes first but "publishers" comes second and "general" is last.

Here :

<?
$fruits = Array( 
    "apples" => Array (
        "one",
        "two",
        "three"
    ),
    "oranges" => Array (
        "one",
        "two",
        "three"
    ),
    "bananas" => Array (
        "one",
        "two",
        "three"
    )
);
ksort($fruits);
foreach ($fruits as $key => $val) {
    echo "$key = $val
";
}
?>

Output:

apples = Array 
bananas = Array  
oranges = Array

You should use ksort. It sorts the array in alphabetic order by the array keys. Something like this

<?php
 $arr = array('general'=>array(1,2,3), 'advertisers'=>array(7,8,9), 'publishers'=>array(11,12,13));
 ksort($arr);
 print '<pre>';
 print_r($arr);
 print '</pre>';
?>

Output

Array
(
[advertisers] => Array
    (
        [0] => 7
        [1] => 8
        [2] => 9
    )

[general] => Array
    (
        [0] => 1
        [1] => 2
        [2] => 3
    )

[publishers] => Array
    (
        [0] => 11
        [1] => 12
        [2] => 13
    )

 )