displaying multiple lines of a file, never repeating

后端 未结 4 1304
执笔经年
执笔经年 2020-12-04 02:48

i need to, for every ten lines, echo them in a div.

example:

line 1 line 2 ... line 9 line 10
4条回答
  •  眼角桃花
    2020-12-04 03:23

    This should work:

    $blocks = array_chunk(file('path/to/file'), 10);
    foreach($blocks as $number => $block) {
        printf('
    %s
    ', $number+1, implode('
    ', $block)); }

    References:

    • array_chunk()
    • printf()

提交回复
热议问题