0

我有两个这样的数组:

数组 1 的 x 轴值在数组中 y 轴值在数组中

x-array: ["04 Feb","05 Feb","06 Feb","07 Feb","08 Feb","09 Feb","10 Feb"]
y-array: [3.27,3.34,3.27,3.2,3.28,3.17,3.15]

Array2 在数组中具有 x 轴值 y 轴值在数组中

x-array2: ["11 Feb", "12 Feb"]
y-array2: [3.19, 3.36]

如何使用键值对创建多维数组。

就像下面的php

Array
(
    [0] => Array
        (
            [x-axis] => Array
                (
                    [0] => 04 Feb
                    [1] => 05 Feb
                    [2] => 06 Feb
                    [3] => 07 Feb
                    [4] => 08 Feb
                    [5] => 09 Feb
                    [6] => 10 Feb
                )

            [y-axis] => Array
                (
                    [0] => 3.27
                    [1] => 3.34
                    [2] => 3.27
                    [3] => 3.2
                    [4] => 3.28
                    [5] => 3.17
                    [6] => 3.15
                )

        )

    [1] => Array
        (
            [x-axis] => Array
                (
                    [0] => 11 Feb
                    [1] => 12 Feb
                )

            [y-axis] => Array
                (
                    [0] => 3.19
                    [1] => 3.36
                )

        )

)
4

2 回答 2

1
$array = array(
  0 => array(
    "x-axis" => $x_array,
    "y-axis" => $y_array),
  1 => array(
    "x-axis" => $x_array2,
    "y-axis" => $y_array2)
) ;

var_dump($array) ;
于 2013-02-19T11:42:45.490 回答
1
$new_array = array(array("x-axis"=>$x-axis-array,
                         "y-axis"=>$y-axis-array
                        ),
                   array("x-axis"=>$x-axis-array2,
                         "y-axis"=>$y-axis-array2
                        )
                  );

echo "<pre>";
print_r($new_array);
于 2013-02-19T11:43:28.090 回答