foreach problem
fgg
fgg 2021-07-16 18:50:15
0
2
1372

Why does the foreach output name appear double (PS has only two fields)

<?
for($iCnt2 = 0; $iCnt2 < sqlsrv_num_fields($result); $iCnt2++) {
    foreach( sqlsrv_field_metadata( $result) as $v ){
        echo "<td  align=center>". $v['Name']."</td>" ;
    }
}
?>

微信图片_20210716184752.png

fgg
fgg

reply all(2)
Kay

Using foreach to traverse in a for loop is equivalent to looping the traversal again. You can know the difference between for and foreach in Baidu.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!