PHP:flatten array - 最快的方法?

Ind*_*ial 5 php arrays

有没有快速的方法来展平数组并选择子键(在这种情况下为'key'和'value')而不运行foreach循环,或者foreach总是最快的方式?

Array
(
    [0] => Array
        (
            [key] => string
            [value] => a simple string
            [cas] => 0
        )

    [1] => Array
        (
            [key] => int
            [value] => 99
            [cas] => 0
        )

    [2] => Array
        (
            [key] => array
            [value] => Array
                (
                    [0] => 11
                    [1] => 12
                )

            [cas] => 0
        )

)
Run Code Online (Sandbox Code Playgroud)

至:

Array
(
    [int] => 99
    [string] => a simple string
    [array] => Array
        (
            [0] => 11
            [1] => 12
        )
)
Run Code Online (Sandbox Code Playgroud)

irc*_*ell 3

试一试:

$ret = array();
while ($el = each($array)) {
    $ret[$el['value']['key']] = $el['value']['value'];
}
Run Code Online (Sandbox Code Playgroud)