【问题标题】:I want to return the next value each time in $values ​with for我想每次在 $values 中用 for 返回下一个值
【发布时间】:2022-06-14 21:17:05
【问题描述】:

我正在尝试使用 Laravel 导出。有一个数组,它返回 2 个值。如:

items: array:2 [▼
    0 => "90"
    1 => "600"
  ]

我想在excel中显示这两个值,但是总是说90,怎么办?

for ($i = 0; $i <count($this->values); $i++) {
    $values[$i]=$this->values[$i];
        
    return [
            //$videohistory->user_id,
            //emoji_decode($videohistory->publisher->nick_name),
            date("Y-m-d H:i:s", $videohistory->create_time),
            date("Y-m-d H:i:s", $videohistory->end_time),
            diff_date_format($videohistory->begin_time, $videohistory->end_time, "%H sa %i dk. %s sn"),
            $values[$i],
        ];    
}

【问题讨论】:

  • 您将返回 for 循环内部,因此它只会显示第一次迭代。您必须建立一个数组,并在循环后返回它。

标签: php arrays laravel for-loop foreach


猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-03-09
  • 2017-02-25
  • 2019-09-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多