배열
10.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | <!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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | <!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> |