在php中为循环返回数据

在php中为循环返回数据,php,for-loop,Php,For Loop,让我们在变量中获取循环的输出,我尝试在for循环中返回数据。代码如下: <?php for($i=0,$j=0; $i<=10, $j<=10; $i++,$j++){ $data = "$i and $j<br>"; return $data; } echo $data; ?> 这是代码 所以,如何在php中为循环返回数据,所以有办法在循环之外使用循环数据 试试: $data = ''; for($i=0,$j=0; $i<=10

让我们在变量中获取循环的输出,我尝试在for循环中返回数据。代码如下:

<?php
for($i=0,$j=0; $i<=10, $j<=10; $i++,$j++){
    $data = "$i and $j<br>";
    return $data;
}
echo $data;
?>

这是代码
所以,如何在php中为循环返回数据,所以有办法在循环之外使用循环数据

试试:

$data = '';
for($i=0,$j=0; $i<=10, $j<=10; $i++,$j++){
    $data .= "$i and $j<br/>";
}
echo $data;
$data='';

对于($i=0,$j=0;$i这真的是你想要的循环吗?11,22,33? 要让11、12、13……执行以下操作:

$data = '';
for($i=0; $i<=10; $i++){
    for($j=0; $j<=10; $j++){
        $data .= "$i and $j<br/>";
    }
}
echo $data;
$data='';
对于($i=0;$i)