Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/242.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在PHP中创建二维数组以转换为不带键的JSON数组_Php_Arrays_Json - Fatal编程技术网

在PHP中创建二维数组以转换为不带键的JSON数组

在PHP中创建二维数组以转换为不带键的JSON数组,php,arrays,json,Php,Arrays,Json,如何在php中创建一个二维数组,稍后可以将其转换为不带键的JSON数组?最后的结果是一个变量,我想在Java脚本中响应它,它应该如下所示: [['2012-03-01 05:06:00',37], ['2012-03-01 05:07:00',38], ['2012-03-01 10:07:00',38], ['2012-03-01 10:07:01',39], ['2012-03-01

如何在php中创建一个二维数组,稍后可以将其转换为不带键的JSON数组?最后的结果是一个变量,我想在Java脚本中响应它,它应该如下所示:

      [['2012-03-01 05:06:00',37],
            ['2012-03-01 05:07:00',38],
            ['2012-03-01 10:07:00',38],
            ['2012-03-01 10:07:01',39], 
            ['2012-03-01 11:07:01',38],        
            ],
array_push($date,(string)$r['datTime']);
我可以用php创建一维数组,如下所示:

      [['2012-03-01 05:06:00',37],
            ['2012-03-01 05:07:00',38],
            ['2012-03-01 10:07:00',38],
            ['2012-03-01 10:07:01',39], 
            ['2012-03-01 11:07:01',38],        
            ],
array_push($date,(string)$r['datTime']);
然后使用以下命令将其转换为JSON数组:

$jsonDate = json_encode($date);

但这是如何在二维或更高维度上工作的呢?

two在PHP中创建一个二维数组以将其转换为JSON:

    $Data = array();
    $TwoDim = array(["Hallo", "Welt"]);
    array_push($Data,$TwoDim);
    $jsonData = json_encode($Data);

你能用同样的方法告诉我们你的预期产量吗?json_encode不在乎。输出应该是一个二维json数组:
['2012-03-01 05:06:00',37],'2012-03-01 05:07:00',38],'2012-03-01 10:07:00',38],'2012-03-01 10:07:01',39],'2012-03-01 11:07:01',38]]
请提供1)我们可以用来复制您的问题的代码,2)问题是什么,3)预期输出。
$twoDimensions=[[['valuehere','other'],['even','more','values']是一个没有键的二维数组。