Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/kotlin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 尝试在for loop语句内部循环foreach_Php_Laravel_Loops - Fatal编程技术网

Php 尝试在for loop语句内部循环foreach

Php 尝试在for loop语句内部循环foreach,php,laravel,loops,Php,Laravel,Loops,我正在尝试在laravel控制器中foreach内部for循环 我试过这样做: $text = ""; $text1 = ""; $sesis = Sesi::all(); for($i=$start_time; $i<$end_time; $i+=86400) { $text .= "<tr> <td>".date('d F Y', $i)."</td". foreach ($sesis as $dat

我正在尝试在laravel控制器中foreach内部for循环

我试过这样做:

$text = "";
$text1 = "";
$sesis = Sesi::all();
for($i=$start_time; $i<$end_time; $i+=86400)
    {
        $text .= "<tr>
        <td>".date('d F Y', $i)."</td".
        foreach ($sesis as $data) {
            $text1 .="<td><button>$data->id</button></td>"
        }."</tr>";
    }
return $text;

我想知道,是否可以在foreach语句中使用foreach?

代码中有语法错误。因此,按如下方式更改代码:

$text = "";
$sesis = Sesi::all();
for($i=$start_time; $i<$end_time; $i+=86400)
    {
        $text .= "<tr><td>".date('d F Y', $i)."</td>";
        foreach ($sesis as $data) {
            $text .="<td><button>".$data->id."</button></td>";
        }
        $text = $text."</tr>";
    }
return $text;

你有一个简单的sintax错误,首先尝试更改。日期'F Y',$i。谢谢你的回复,我已经更改了它,但是,像以前一样的错误如果你有相同的错误检查你的语法,现在必须检查Sagar的Answit,它应该可以工作谢谢你,先生,它像一个符咒一样工作,现在,你能告诉我如何在foreach语句中使用foreach吗?please@FajarAlamRahmatSidik只需为每个内部foreach添加另一个
$text = "";
$sesis = Sesi::all();
for($i=$start_time; $i<$end_time; $i+=86400)
    {
        $text .= "<tr><td>".date('d F Y', $i)."</td>";
        foreach ($sesis as $data) {
            $text .="<td><button>".$data->id."</button></td>";
        }
        $text = $text."</tr>";
    }
return $text;