Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/14.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_Json_Split_Divide - Fatal编程技术网

使用php将JSON分成相等的较小部分

使用php将JSON分成相等的较小部分,php,json,split,divide,Php,Json,Split,Divide,我有一个包含14个元素的JSON。 我如何将它划分为更小的json,每个json包含2或3个元素。不知道确切的json是什么,但这将作为一个示例: <?php $jsonExample = '["a","b","c","d","e","f","g","h","i"]' ; $arrResult = json_decode($jsonExample,true); $output = array_chunk($arrResult,3); var_dump($output); ?>

我有一个包含14个元素的JSON。
我如何将它划分为更小的json,每个json包含2或3个元素。

不知道确切的json是什么,但这将作为一个示例:

<?php

$jsonExample = '["a","b","c","d","e","f","g","h","i"]' ;
$arrResult = json_decode($jsonExample,true);
$output = array_chunk($arrResult,3);
var_dump($output);

?>


演示:

不知道确切的json是什么,但这将作为一个示例:

<?php

$jsonExample = '["a","b","c","d","e","f","g","h","i"]' ;
$arrResult = json_decode($jsonExample,true);
$output = array_chunk($arrResult,3);
var_dump($output);

?>


演示:

我建议使用json\u decode()和array\u chunk()


我建议使用json_decode()和array_chunk()


请给我们看一些代码。请给我们看一些代码。