0

我有一个数组,它是一个按日期排序的数组数组,如下所示:

Array
(
    [1379167200] => Array
        (
            [110] => Introduction to Banking | Saturday, September 14, 2013 - 10:00am
        )

    [1380376800] => Array
        (
            [71] => Saving, Investing, Debt | Saturday, September 28, 2013 - 10:00am
        )

    [1381588200] => Array
        (
            [72] => Setting Personal Goals | Saturday, October 12, 2013 - 10:30am
        )

    [1382796000] => Array
        (
            [74] => Type of Account: What's Right for You? | Saturday, October 26, 2013 - 10:00am
        )

    [1384009200] => Array
        (
            [81] => Creating an Account: Learning to Budget | Saturday, November 09, 2013 - 10:00am
        )
)

我想保持排序(即按日期排序),但最好只在单个数组中包含最内部的数组项。像这样:

Array
(
        [110] => Introduction to Banking | Saturday, September 14, 2013 - 10:00am

        [71] => Saving, Investing, Debt | Saturday, September 28, 2013 - 10:00am

        [72] => Setting Personal Goals | Saturday, October 12, 2013 - 10:30am

        [74] => Type of Account: What's Right for You? | Saturday, October 26, 2013 - 10:00am

        [81] => Creating an Account: Learning to Budget | Saturday, November 09, 2013 - 10:00am
)

这怎么可能?我需要将整数转换为字符串吗?

我绝对需要维护按日期排序,但我还需要维护整数键和值之间的关系,两者都使用。

4

1 回答 1

1

遍历数组,创建新数组:

$newArray = Array();
foreach($array as $row) { // $row is subarray
   $value = current($row); // first value in subarray "Itroduction to ..."
   $key = key($row); // first key in subarray 101, 71, 72
   $newArray[$key] = $value;
}

演示;

文件:

于 2013-10-10T21:29:35.610 回答