大概是php7,新增的特性。
<?php
//array数组使用foreach循环的方式
$array1 = array('one','two','three');
foreach ($array1 as $arr1)
{
echo "值为:$arr1"."<br>";
}
echo "<hr>";
//不带{},有:替代的循环编写方式
$min = 1;
$max = 10;
$temparray = array();
$temparray[0][0] = 1;
for($i=1; $i<$max; $i++):
for($j=0; $j<=$i; $j++):
if($j==0 or $j==$i):
$temparray[$i][$j] = 1;
else:
$temparray[$i][$j] = $temparray[$i-1][$j-1] + $temparray[$i-1][$j];
endif;
endfor;
endfor;
foreach ($temparray as $value):
foreach ($value as $vl):
echo $vl." ";
endforeach;
echo "<p>";
endforeach;