doulai2025 2015-10-27 13:12
浏览 23

PHP获取foreach项的所有字符并放在第二页


I have a small invoice web tool.
So I would like to find out the total amount of all positions of items and if it reached a maximum level it should print the following positions on the second page of the invoice.

I use the sample code to "design" my invoices:
http://codepen.io/rafaelcastrocouto/pen/LFAes/

My idea is: first count all characters of the foreach loop.
But I don't know how I should continue?
Please give me some hints. Thanks

EDIT: here is my foreach loop code:

<?php foreach( $items as $it): ?>
        <tr class="even">
          <td style="width:8%;"><?php echo $pos; ?></td>
          <td style="width:47%;"><?php 
          $string = $it->invoice_item_text;
          if (strlen($string) > 350) $string = substr($string,0,350).'...';
                  echo $string; 
                  ?></td>
          <td style="width:15%;">
          <?php if ($it->invoice_item_type == 3) {$date = date('M Y', strtotime($it->invoice_item_date)); } else { $date = date('d.m.Y', strtotime($it->invoice_item_date)); } ?>
            <?php echo $date; ?>
          </td>
          <td style="width:20%;"><?php if ($it->invoice_item_time != '0') { if ($it->invoice_item_type == 1 or $it->invoice_item_type == 2) echo gmdate('H:i', $it->invoice_item_time);}; ?></td>
          <td style="width:10%;"><?php echo number_format($it->invoice_item_sum, 2, ',', ' '); ?> €</td>
        </tr>
        <?php $pos++; ?
        <?php endforeach; ?> 
  • 写回答

1条回答 默认 最新

  • duanbei3704 2015-10-27 13:17
    关注

    Use php Array as session variable

    $_SESSION['items'] = $items;
    

    if you store value in session you can use this value any page

    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大