Notice
Recent Posts
Recent Comments
Link
250x250
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
Tags
- mysql
- Algorithm
- php
- web
- computer
- DATAPATH
- Java
- control
- Pipelining
- javascript
- react
- Linux
- function
- DB
- data structure
- Class
- html
- XML
- DS
- instruction
- architecture
- system
- python
- openai
- MIPS
- for
- CSS
- github
- Rag
- AI
Archives
- Today
- Total
YYYEJI
[PHP] PHP의 다차원 Array 본문
728x90

Array란?
맵(map)으로 이루어진, 순서가 있는 집합을 의미합니다.
↓↓↓ 1차원 Array 공부하기 ↓↓↓
https://yyyeji.tistory.com/303
기본적은 문법은 아래와 같습니다.
$nums = array(
array("One", " : ", 1),
array("Two", " : ", 2),
array("Three", " : ", 3)
);
기본적은 출력은 아래와 같습니다.
<!EOCTYPE html>
<body>
<h1>My first PHP page</h1>
<?php
$nums = array(
array("One", " : ", 1),
array("Two", " : ", 2),
array("Three", " : ", 3)
);
echo $nums[0][0].$nums[0][1].$nums[0][2]."<br>";
echo $nums[1][0].$nums[1][1].$nums[1][2]."<br>";
echo $nums[2][0].$nums[2][1].$nums[2][2];
?>
</body>

For statement를 이용한 출력은 아래와 같습니다.
<!EOCTYPE html>
<body>
<h1>My first PHP page</h1>
<?php
$nums = array(
array("One", " : ", 1),
array("Two", " : ", 2),
array("Three", " : ", 3)
);
for ($row = 0; $row<3; $row++){
for($col = 0; $col<3; $col++) {
echo $nums[$row][$col]." ";
}
echo "<br>";
}
?>
</body>

◡̈
728x90
'HTML(or XML) & CSS & JavaScript' 카테고리의 다른 글
| [PHP] Super Globals 란? (0) | 2022.12.12 |
|---|---|
| [PHP] PHP의 Associative Array (0) | 2022.12.12 |
| [PHP] PHP의 1차원 Array (0) | 2022.12.12 |
| [PHP] 함수 만들기 (0) | 2022.12.12 |
| [PHP] Class 만들기 (0) | 2022.12.12 |