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개
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 8130 | 9년 전 | 523 | ||
| 8129 |
|
9년 전 | 655 | |
| 8128 | 9년 전 | 521 | ||
| 8127 |
|
9년 전 | 577 | |
| 8126 | 9년 전 | 510 | ||
| 8125 | 9년 전 | 772 | ||
| 8124 |
|
9년 전 | 528 | |
| 8123 | 9년 전 | 507 | ||
| 8122 | 9년 전 | 440 | ||
| 8121 | 9년 전 | 547 | ||
| 8120 | 9년 전 | 469 | ||
| 8119 | 9년 전 | 553 | ||
| 8118 |
|
9년 전 | 636 | |
| 8117 |
|
9년 전 | 408 | |
| 8116 |
PASKRAN
|
9년 전 | 472 | |
| 8115 | 9년 전 | 460 | ||
| 8114 |
kiplayer
|
9년 전 | 601 | |
| 8113 | 9년 전 | 455 | ||
| 8112 |
|
9년 전 | 560 | |
| 8111 | 9년 전 | 412 | ||
| 8110 | 9년 전 | 446 | ||
| 8109 | 9년 전 | 379 | ||
| 8108 |
|
9년 전 | 547 | |
| 8107 |
|
9년 전 | 442 | |
| 8106 |
|
9년 전 | 445 | |
| 8105 | 9년 전 | 479 | ||
| 8104 |
|
9년 전 | 438 | |
| 8103 |
|
9년 전 | 438 | |
| 8102 |
|
9년 전 | 406 | |
| 8101 |
snshero
|
9년 전 | 792 | |
| 8100 | 9년 전 | 847 | ||
| 8099 | 9년 전 | 818 | ||
| 8098 | 9년 전 | 716 | ||
| 8097 | 9년 전 | 524 | ||
| 8096 | 9년 전 | 719 | ||
| 8095 | 9년 전 | 851 | ||
| 8094 | 9년 전 | 523 | ||
| 8093 | 9년 전 | 807 | ||
| 8092 | 9년 전 | 763 | ||
| 8091 | 9년 전 | 1148 | ||
| 8090 | 9년 전 | 774 | ||
| 8089 | 9년 전 | 980 | ||
| 8088 | 9년 전 | 654 | ||
| 8087 | 9년 전 | 773 | ||
| 8086 | 9년 전 | 526 | ||
| 8085 | 9년 전 | 493 | ||
| 8084 | 9년 전 | 615 | ||
| 8083 | 9년 전 | 582 | ||
| 8082 | 9년 전 | 765 | ||
| 8081 | 9년 전 | 475 | ||
| 8080 | 9년 전 | 574 | ||
| 8079 | 9년 전 | 533 | ||
| 8078 | 9년 전 | 456 | ||
| 8077 | 9년 전 | 535 | ||
| 8076 | 9년 전 | 414 | ||
| 8075 | 9년 전 | 448 | ||
| 8074 | 9년 전 | 406 | ||
| 8073 | 9년 전 | 462 | ||
| 8072 | 9년 전 | 458 | ||
| 8071 |
o1o111
|
9년 전 | 903 | |
| 8070 | 9년 전 | 410 | ||
| 8069 | 9년 전 | 347 | ||
| 8068 | 9년 전 | 599 | ||
| 8067 | 9년 전 | 399 | ||
| 8066 | 9년 전 | 430 | ||
| 8065 | 9년 전 | 391 | ||
| 8064 | 9년 전 | 376 | ||
| 8063 | 9년 전 | 344 | ||
| 8062 | 9년 전 | 313 | ||
| 8061 | 9년 전 | 354 | ||
| 8060 | 9년 전 | 397 | ||
| 8059 | 9년 전 | 334 | ||
| 8058 | 9년 전 | 259 | ||
| 8057 | 9년 전 | 392 | ||
| 8056 | 9년 전 | 314 | ||
| 8055 | 9년 전 | 359 | ||
| 8054 | 9년 전 | 370 | ||
| 8053 | 9년 전 | 418 | ||
| 8052 | 9년 전 | 296 | ||
| 8051 | 9년 전 | 341 | ||
| 8050 | 9년 전 | 398 | ||
| 8049 | 9년 전 | 329 | ||
| 8048 | 9년 전 | 440 | ||
| 8047 | 9년 전 | 370 | ||
| 8046 | 9년 전 | 316 | ||
| 8045 | 9년 전 | 267 | ||
| 8044 | 9년 전 | 352 | ||
| 8043 | 9년 전 | 301 | ||
| 8042 | 9년 전 | 299 | ||
| 8041 | 9년 전 | 361 | ||
| 8040 | 9년 전 | 281 | ||
| 8039 | 9년 전 | 324 | ||
| 8038 | 9년 전 | 274 | ||
| 8037 | 9년 전 | 413 | ||
| 8036 | 9년 전 | 495 | ||
| 8035 | 9년 전 | 440 | ||
| 8034 | 9년 전 | 398 | ||
| 8033 | 9년 전 | 355 | ||
| 8032 | 9년 전 | 450 | ||
| 8031 | 9년 전 | 359 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기