dowy77780 2012-04-03 08:53
浏览 6
已采纳

Php阵列拼接

I am new to php and was wondering if anybody could help me with splitting an array of sentences.

I want to divide the array into two parts, and then divide the first part again into 10 parts, and echo the results.

If I had 100 sentences it would look like this:

echo $Part1-1;  // 5 Sentences
echo $Part1-2;  // 5 Sentences
echo $Part1-3;  // 5 Sentences
echo $Part1-4;  // 5 Sentences
echo $Part1-5;  // 5 Sentences
echo $Part1-6;  // 5 Sentences
echo $Part1-7;  // 5 Sentences
echo $Part1-8;  // 5 Sentences
echo $Part1-9;  // 5 Sentences
echo $Part1-10; // 5 Sentences

echo $Part2; // 50 Sentences

If there are not enough sentences then Part1, X to 10 should be blank.

Thanks

  • 写回答

1条回答 默认 最新

  • douzhaolu4780 2012-04-03 08:55
    关注
    $outerParts = array_chunk($sentences, 50);
    $innerParts1 = array_chunk($outerParts[0], 5);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 无刷电机要通过什么才能做各种动作
  • ¥15 VS2010通过OnCtlColor函数改变radio控件字体的颜色为白色,但是程序运行后发现不起作用,怎么办?
  • ¥15 Qt中实现子线程和管理线程类之间实时通信
  • ¥15 cacls 命令如何解除锁定文件夹?
  • ¥50 C++使用TWAIN协议如何实现A3幅面扫描仪扫描A4横向
  • ¥15 Vue3重构Nuxt3,出现客户端数据和服务端数据不一致的情况
  • ¥15 如何在sql server里完成筛选
  • ¥15 请问为什么我配置IPsec后PC1 ping不通 PC2,抓包出来数据包也并没有被加密
  • ¥200 求博主教我搞定neo4j简易问答系统,有偿
  • ¥15 nginx的使用与作用