duan1979768678 2018-05-11 05:07
浏览 7
已采纳

如何得到数组PHP

i do this on php and can't combine right array

array (
  0 => 'uttt',
)

must add to array

  0 => '534',
  1 => 'DT 8060',
  2 => '6y45y',
  **4 => 'uttt',**

and all arrays must do also i not know how much will array this do in foreach please people help me

array (
  0 => 'uttt',
)
array (
  0 => '534',
  1 => 'DT 8060',
  2 => '6y45y',
)
array (
  0 => '639',
  1 => 'DP 42',
  2 => '88765',
)
array (
  0 => '1470',
  1 => '95126F',
  2 => 'yt44y5',
)
array (
  0 => '1473',
  1 => '95406F',
  2 => 'yyynb rt',
)
array (
  0 => 'ytree',
)
array (
  0 => '3338',
  1 => 'DI 113 ШК',
  2 => 'rdde',
)
array (
  0 => '1476',
  1 => '96010',
  2 => 'ouuhh',
)
array (
  0 => 'nnggg',
)
array (
  0 => '2169',
  1 => 'DT 88263-2',
  2 => 'rhrd',
)
array (
  0 => '2657',
  1 => 'DP 10-1',
  2 => 'klii',
)
array (
  0 => 'ergerg',
)
array (
  0 => '544',
  1 => '96205',
  2 => 'njnj sgsg',
)

me need get such array

    array (
      0 => '534',
      1 => 'DT 8060',
      2 => '6y45y',
      3 => 'uttt',
    )
    array (
      0 => '639',
      1 => 'DP 42',
      2 => '88765',
       3 => 'uttt',
    )
    array (
      0 => '1470',
      1 => '95126F',
      2 => 'yt44y5',
      3 => 'uttt',
    )
    array (
      0 => '1473',
      1 => '95406F',
      2 => 'yyynb rt',
      3 => 'uttt',
    )
    array (
      0 => '3338',
      1 => 'DI 113 ШК',
      2 => 'rdde',
      3 => 'ytree',
    )
    array (
      0 => '1476',
      1 => '96010',
      2 => 'ouuhh',
      3 => 'ytree',
    )
    array (
      0 => '2169',
      1 => 'DT 88263-2',
      2 => 'rhrd',
      3 => 'nnggg',
    )
    array (
      0 => '2657',
      1 => 'DP 10-1',
      2 => 'klii',
      3 => 'nnggg',
    )
    array (
      0 => '544',
      1 => '96205',
      2 => 'njnj sgsg',
      0 => 'ergerg',
    )

how do this? i'am not know

</div>
  • 写回答

4条回答 默认 最新

  • douding6266 2018-05-11 05:14
    关注
    $result = [];
    $arrayToMerge = [];
    foreach ($arrays as $array) {
        if (count($array) == 1) {
            $arrayToMerge = $array;
        }
        else {
            $result[] = array_push($array, $arrayToMerge);
        }
    }
    return $result;
    

    Try this

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?