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년 전 | 577 | ||
| 8129 |
|
9년 전 | 696 | |
| 8128 | 9년 전 | 551 | ||
| 8127 |
|
9년 전 | 594 | |
| 8126 | 9년 전 | 533 | ||
| 8125 | 9년 전 | 782 | ||
| 8124 |
|
9년 전 | 542 | |
| 8123 | 9년 전 | 528 | ||
| 8122 | 9년 전 | 458 | ||
| 8121 | 9년 전 | 569 | ||
| 8120 | 9년 전 | 483 | ||
| 8119 | 9년 전 | 575 | ||
| 8118 |
|
9년 전 | 651 | |
| 8117 |
|
9년 전 | 418 | |
| 8116 |
PASKRAN
|
9년 전 | 475 | |
| 8115 | 9년 전 | 474 | ||
| 8114 |
kiplayer
|
9년 전 | 613 | |
| 8113 | 9년 전 | 470 | ||
| 8112 |
|
9년 전 | 581 | |
| 8111 | 9년 전 | 420 | ||
| 8110 | 9년 전 | 458 | ||
| 8109 | 9년 전 | 391 | ||
| 8108 |
|
9년 전 | 568 | |
| 8107 |
|
9년 전 | 456 | |
| 8106 |
|
9년 전 | 457 | |
| 8105 | 9년 전 | 488 | ||
| 8104 |
|
9년 전 | 452 | |
| 8103 |
|
9년 전 | 455 | |
| 8102 |
|
9년 전 | 426 | |
| 8101 |
snshero
|
9년 전 | 815 | |
| 8100 | 9년 전 | 858 | ||
| 8099 | 9년 전 | 837 | ||
| 8098 | 9년 전 | 741 | ||
| 8097 | 9년 전 | 544 | ||
| 8096 | 9년 전 | 746 | ||
| 8095 | 9년 전 | 882 | ||
| 8094 | 9년 전 | 550 | ||
| 8093 | 9년 전 | 831 | ||
| 8092 | 9년 전 | 778 | ||
| 8091 | 9년 전 | 1164 | ||
| 8090 | 9년 전 | 791 | ||
| 8089 | 9년 전 | 1000 | ||
| 8088 | 9년 전 | 662 | ||
| 8087 | 9년 전 | 791 | ||
| 8086 | 9년 전 | 538 | ||
| 8085 | 9년 전 | 505 | ||
| 8084 | 9년 전 | 623 | ||
| 8083 | 9년 전 | 595 | ||
| 8082 | 9년 전 | 785 | ||
| 8081 | 9년 전 | 497 | ||
| 8080 | 9년 전 | 593 | ||
| 8079 | 9년 전 | 550 | ||
| 8078 | 9년 전 | 468 | ||
| 8077 | 9년 전 | 557 | ||
| 8076 | 9년 전 | 428 | ||
| 8075 | 9년 전 | 459 | ||
| 8074 | 9년 전 | 427 | ||
| 8073 | 9년 전 | 480 | ||
| 8072 | 9년 전 | 473 | ||
| 8071 |
o1o111
|
9년 전 | 923 | |
| 8070 | 9년 전 | 431 | ||
| 8069 | 9년 전 | 369 | ||
| 8068 | 9년 전 | 620 | ||
| 8067 | 9년 전 | 420 | ||
| 8066 | 9년 전 | 444 | ||
| 8065 | 9년 전 | 406 | ||
| 8064 | 9년 전 | 401 | ||
| 8063 | 9년 전 | 367 | ||
| 8062 | 9년 전 | 338 | ||
| 8061 | 9년 전 | 373 | ||
| 8060 | 9년 전 | 417 | ||
| 8059 | 9년 전 | 352 | ||
| 8058 | 9년 전 | 291 | ||
| 8057 | 9년 전 | 417 | ||
| 8056 | 9년 전 | 335 | ||
| 8055 | 9년 전 | 383 | ||
| 8054 | 9년 전 | 387 | ||
| 8053 | 9년 전 | 439 | ||
| 8052 | 9년 전 | 310 | ||
| 8051 | 9년 전 | 359 | ||
| 8050 | 9년 전 | 413 | ||
| 8049 | 9년 전 | 349 | ||
| 8048 | 9년 전 | 452 | ||
| 8047 | 9년 전 | 392 | ||
| 8046 | 9년 전 | 336 | ||
| 8045 | 9년 전 | 284 | ||
| 8044 | 9년 전 | 373 | ||
| 8043 | 9년 전 | 331 | ||
| 8042 | 9년 전 | 317 | ||
| 8041 | 9년 전 | 381 | ||
| 8040 | 9년 전 | 300 | ||
| 8039 | 9년 전 | 344 | ||
| 8038 | 9년 전 | 284 | ||
| 8037 | 9년 전 | 430 | ||
| 8036 | 9년 전 | 518 | ||
| 8035 | 9년 전 | 451 | ||
| 8034 | 9년 전 | 410 | ||
| 8033 | 9년 전 | 371 | ||
| 8032 | 9년 전 | 476 | ||
| 8031 | 9년 전 | 368 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기