Correcting teacher:PHPz
Correction status:qualified
Teacher's comments:php和js都可以通过下标遍历,也都可以不通过下标
<!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循环循环下标然后通过当前下标调取值