배열 2015-03-27 토픽 생활코딩 > WEB > 웹 애플리케이션 만들기 배열 10.php <!DOCTYPE html> <html> <head> <meta charset="utf-8"> </head> <body> <h1>JavaScript</h1> <script> list = new Array("one", "two", "three"); document.write(list[2]); document.write(list.length); </script> <h1>php</h1> <?php $list = array("one", "two", "three"); echo $list[2]; echo count($list); ?> </body> </html> 배열과 반복문 11.php <!DOCTYPE html> <html> <head> <meta charset="utf-8"> </head> <body> <h1>JavaScript</h1> <ul> <script> list = new Array("최진혁", "최유빈", "한이람", "한이은", "이고잉"); i = 0; while(i < list.length){ document.write("<li>"+list[i]+"</li>"); i = i + 1; } </script> </ul> <h1>php</h1> <ul> <?php $list = array("최진혁", "최유빈", "한이람", "한이은"); $i = 0; while($i < count($list)){ echo "<li>".$list[$i]."</li>"; $i = $i + 1; } ?> </ul> </body> </html> 소스코드 github