in_array
(PHP 4, PHP 5, PHP 7)
in_array — 값이 배열 안에 존재하는지 확인
설명 ¶
bool in_array ( mixed $needle , array $haystack [, bool $strict ] )
인수 ¶
needle
찾을 값.
Note:
needle이 문자열이면, 대소문자를 구분하여 비교합니다.
haystack
배열.
strict
세번째 인수 strict를 TRUE로 설정하면, in_array() 함수는 haystack 안에서 needle의 자료형도 확인합니다.
반환값 ¶
needle을 배열에서 찾으면 TRUE를, 아니면 FALSE를 반환합니다.
Example #1 in_array() 예제
<?php
$os = array("Mac", "NT", "Irix", "Linux");
if (in_array("Irix", $os)) {
echo "Got Irix";
}
if (in_array("mac", $os)) {
echo "Got mac";
}
?>
in_array()가 대소문자를 구분하므로 두번째 조건은 실패하고, 위 프로그램은 다음을 출력합니다:
output :
Got Irix
Example #2 in_array()에 strict 예제
<?php
$a = array('1.10', 12.4, 1.13);
if (in_array('12.4', $a, true)) {
echo "'12.4' found with strict check\n";
}
if (in_array(1.13, $a, true)) {
echo "1.13 found with strict check\n";
}
?>
위 예제의 출력:
1.13 found with strict check
Example #3 in_array()에 needle로 배열
<?php
$a = array(array('p', 'h'), array('p', 'r'), 'o');
if (in_array(array('p', 'h'), $a)) {
echo "'ph' was found\n";
}
if (in_array(array('f', 'i'), $a)) {
echo "'fi' was found\n";
}
if (in_array('o', $a)) {
echo "'o' was found\n";
}
?>
위 예제의 출력:
'ph' was found
'o' was found
댓글 1개
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 8230 | 9년 전 | 92 | ||
| 8229 | 9년 전 | 94 | ||
| 8228 |
커네드커네드
|
9년 전 | 136 | |
| 8227 | 9년 전 | 158 | ||
| 8226 | 9년 전 | 186 | ||
| 8225 | 9년 전 | 173 | ||
| 8224 | 9년 전 | 166 | ||
| 8223 | 9년 전 | 136 | ||
| 8222 |
|
9년 전 | 207 | |
| 8221 | 9년 전 | 117 | ||
| 8220 | 9년 전 | 132 | ||
| 8219 | 9년 전 | 117 | ||
| 8218 | 9년 전 | 165 | ||
| 8217 |
star3840
|
9년 전 | 134 | |
| 8216 | 9년 전 | 184 | ||
| 8215 | 9년 전 | 139 | ||
| 8214 | 9년 전 | 246 | ||
| 8213 | 9년 전 | 189 | ||
| 8212 | 9년 전 | 108 | ||
| 8211 | 9년 전 | 276 | ||
| 8210 | 9년 전 | 273 | ||
| 8209 | 9년 전 | 360 | ||
| 8208 | 9년 전 | 249 | ||
| 8207 | 9년 전 | 245 | ||
| 8206 |
|
9년 전 | 212 | |
| 8205 | 9년 전 | 198 | ||
| 8204 | 9년 전 | 155 | ||
| 8203 | 9년 전 | 252 | ||
| 8202 | 9년 전 | 166 | ||
| 8201 | 9년 전 | 200 | ||
| 8200 | 9년 전 | 191 | ||
| 8199 | 9년 전 | 237 | ||
| 8198 | 9년 전 | 202 | ||
| 8197 | 9년 전 | 186 | ||
| 8196 | 9년 전 | 577 | ||
| 8195 | 9년 전 | 182 | ||
| 8194 | 9년 전 | 308 | ||
| 8193 | 9년 전 | 186 | ||
| 8192 | 9년 전 | 220 | ||
| 8191 | 9년 전 | 168 | ||
| 8190 | 9년 전 | 163 | ||
| 8189 | 9년 전 | 225 | ||
| 8188 | 9년 전 | 154 | ||
| 8187 | 9년 전 | 169 | ||
| 8186 | 9년 전 | 164 | ||
| 8185 | 9년 전 | 341 | ||
| 8184 | 9년 전 | 129 | ||
| 8183 | 9년 전 | 340 | ||
| 8182 | 9년 전 | 197 | ||
| 8181 | 9년 전 | 155 | ||
| 8180 | 9년 전 | 728 | ||
| 8179 | 9년 전 | 509 | ||
| 8178 | 9년 전 | 336 | ||
| 8177 |
kiplayer
|
9년 전 | 349 | |
| 8176 | 9년 전 | 386 | ||
| 8175 | 9년 전 | 252 | ||
| 8174 | 9년 전 | 271 | ||
| 8173 | 9년 전 | 363 | ||
| 8172 | 9년 전 | 229 | ||
| 8171 | 9년 전 | 204 | ||
| 8170 | 9년 전 | 316 | ||
| 8169 |
커네드커네드
|
9년 전 | 280 | |
| 8168 | 9년 전 | 350 | ||
| 8167 | 9년 전 | 340 | ||
| 8166 | 9년 전 | 261 | ||
| 8165 | 9년 전 | 190 | ||
| 8164 | 9년 전 | 326 | ||
| 8163 | 9년 전 | 309 | ||
| 8162 | 9년 전 | 330 | ||
| 8161 | 9년 전 | 318 | ||
| 8160 |
|
9년 전 | 516 | |
| 8159 | 9년 전 | 455 | ||
| 8158 | 9년 전 | 274 | ||
| 8157 | 9년 전 | 401 | ||
| 8156 | 9년 전 | 289 | ||
| 8155 | 9년 전 | 279 | ||
| 8154 |
00년생용띠
|
9년 전 | 623 | |
| 8153 | 9년 전 | 259 | ||
| 8152 |
|
9년 전 | 435 | |
| 8151 | 9년 전 | 441 | ||
| 8150 | 9년 전 | 533 | ||
| 8149 |
Jangfolk
|
9년 전 | 371 | |
| 8148 | 9년 전 | 194 | ||
| 8147 | 9년 전 | 408 | ||
| 8146 | 9년 전 | 473 | ||
| 8145 | 9년 전 | 424 | ||
| 8144 | 9년 전 | 386 | ||
| 8143 | 9년 전 | 221 | ||
| 8142 | 9년 전 | 458 | ||
| 8141 | 9년 전 | 407 | ||
| 8140 | 9년 전 | 952 | ||
| 8139 | 9년 전 | 293 | ||
| 8138 |
전갈자리남자
|
9년 전 | 412 | |
| 8137 | 9년 전 | 426 | ||
| 8136 | 9년 전 | 773 | ||
| 8135 |
|
9년 전 | 817 | |
| 8134 |
PlayPixel
|
9년 전 | 542 | |
| 8133 |
|
9년 전 | 463 | |
| 8132 | 9년 전 | 485 | ||
| 8131 | 9년 전 | 833 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기