Blogger Information
Blog 15
fans 0
comment 0
visits 7785
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
PHP与JS数据遍历
ッ小眼睛っ
Original
381 people have browsed it
  1. <?php
  2. //声明一个php数组
  3. $arr = [
  4. '吃饭',
  5. '睡觉',
  6. '打游戏',
  7. '追剧',
  8. '发呆'
  9. ];
  10. ?>
  11. <!doctype html>
  12. <html lang="en">
  13. <head>
  14. <meta charset="UTF-8">
  15. <meta name="viewport"
  16. content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  17. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  18. <title>小眼睛0802作业</title>
  19. </head>
  20. <body>
  21. <h2><?php echo '你最喜欢做什么?'?></h2>
  22. <!-- 使用foreach遍历数组-->
  23. <ol>
  24. <? foreach ($arr as $v):?>
  25. <li><a><? echo $v?></a></li>
  26. <? endforeach;?>
  27. </ol>
  28. <!-- 使用for循环遍历数组-->
  29. <ul>
  30. <? for ($i=0;$i<count($arr);$i++){?>
  31. <li><a><? echo $arr[$i]?></a></li>
  32. <?}?>
  33. </ul>
  34. <script>
  35. // 声名一个js数组
  36. var arr = [
  37. '吃饭',
  38. '睡觉',
  39. '打游戏',
  40. '追剧',
  41. '发呆'
  42. ];
  43. // 前端不是很好就这样输出吧
  44. for (i=0; i<arr.length; i++){
  45. alert(arr[i]);
  46. }
  47. </script>
  48. </body>
  49. </html>
Correcting teacher:PHPzPHPz

Correction status:qualified

Teacher's comments:
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