Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/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数组项独立于另一个数组_Php_Arrays_Json - Fatal编程技术网

php数组项独立于另一个数组

php数组项独立于另一个数组,php,arrays,json,Php,Arrays,Json,我有一个数组。在这个数组中有156项。我想要的输出格式是 { "status": "OK", "message": "Data Show Successful", "allresult": [ { "id": "", "title": "Yes/No", "details": "Text" } } 前0-19列数据显示如下 状态:好, 信息:数据显示成功 最后2列的值

我有一个数组。在这个数组中有156项。我想要的输出格式是

{
    "status": "OK",
    "message": "Data Show Successful",
    "allresult": [
        {
            "id": "",
            "title": "Yes/No",
            "details": "Text"
        }
}
前0-19列数据显示如下 状态:好, 信息:数据显示成功

最后2列的值也显示相同的值 现在主要的综合体是 第20至155栏 这些数据进入allresult数组 这里每9列显示

{
    "id": "",
    "title": "Yes/No",
    "details": "Text"
}
让我们描述一下 第20列到第155列具有相同的类型数据 每对9列中有相同类型的数据

个人财产 占有长度 露天马车 开放式进位长度 隐蔽的 隐藏长度 隐蔽式(需逆时针) 暗装,不带逆时针,所需长度 笔记 现在我们的allresult输出看起来像是20到37个数字列

"allresult": [
    {
       " possession": "here value of 20",
       "possession___length": " here value of 21",
       " open_cary ": " here value of 22 "
       Up to notes
    },
    {
        " possession": "here value of 29",
        "possession___length": " here value of 30",
        " open_cary ": " here value of 31"
       Up to notes
    }
}
我可以检索所有数据并显示json数组输出,但不能每9列分离第20列到155列数据

检索所有数据

while($row = mysql_fetch_assoc($result)) 
{
    $info[]=$row;
}

$output = array( 'result' =>$info);

echo json_encode($output);

数组块呢?它允许您设置每个块的大小

array\u chunk-将数组拆分为块

描述

数组\u块数组$array,int$size[,bool$preserve\u键= false]将数组分块为具有大小元素的数组。最后 块可能包含小于大小的元素


查看数组\u切片如何在每9次之后切片我的主数组?任何例子@JayBlanchard