Blogger Information
Blog 15
fans 0
comment 0
visits 8366
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
php遍历与js遍历区别
我们的关系如此狭窄
Original
511 people have browsed it
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<script typet="text/javascript" src="http://libs.baidu.com/jquery/1.9.1/jquery.min.js"></script>
<body>

<?php $arr = [1,2,3,4,5]; ?>
<?php foreach ($arr as $k){?>
    <tr>
        <td class="td"><? echo $k;echo "</br>"; ?></td>

    </tr>
<? } ?>


</body>
<script>
    let arr = ['A','B','C','D','E'];
    for(let i =0;i<arr.length;i++){
        alert(arr[i]);
    }
</script>
</html>

php遍历直接把遍历内容赋值到如上的$k,可以直接调用,js中for循环循环下标然后通过当前下标调取值

Correcting teacher:PHPzPHPz

Correction status:qualified

Teacher's comments:php和js都可以通过下标遍历,也都可以不通过下标
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post