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년 전 | 468 | ||
| 8129 |
|
9년 전 | 626 | |
| 8128 | 9년 전 | 502 | ||
| 8127 |
|
9년 전 | 563 | |
| 8126 | 9년 전 | 492 | ||
| 8125 | 9년 전 | 749 | ||
| 8124 |
|
9년 전 | 481 | |
| 8123 | 9년 전 | 471 | ||
| 8122 | 9년 전 | 409 | ||
| 8121 | 9년 전 | 515 | ||
| 8120 | 9년 전 | 446 | ||
| 8119 | 9년 전 | 524 | ||
| 8118 |
|
9년 전 | 613 | |
| 8117 |
|
9년 전 | 384 | |
| 8116 |
PASKRAN
|
9년 전 | 451 | |
| 8115 | 9년 전 | 445 | ||
| 8114 |
kiplayer
|
9년 전 | 585 | |
| 8113 | 9년 전 | 420 | ||
| 8112 |
|
9년 전 | 536 | |
| 8111 | 9년 전 | 390 | ||
| 8110 | 9년 전 | 427 | ||
| 8109 | 9년 전 | 339 | ||
| 8108 |
|
9년 전 | 526 | |
| 8107 |
|
9년 전 | 415 | |
| 8106 |
|
9년 전 | 411 | |
| 8105 | 9년 전 | 457 | ||
| 8104 |
|
9년 전 | 410 | |
| 8103 |
|
9년 전 | 410 | |
| 8102 |
|
9년 전 | 370 | |
| 8101 |
snshero
|
9년 전 | 756 | |
| 8100 | 9년 전 | 819 | ||
| 8099 | 9년 전 | 784 | ||
| 8098 | 9년 전 | 694 | ||
| 8097 | 9년 전 | 486 | ||
| 8096 | 9년 전 | 686 | ||
| 8095 | 9년 전 | 809 | ||
| 8094 | 9년 전 | 486 | ||
| 8093 | 9년 전 | 780 | ||
| 8092 | 9년 전 | 739 | ||
| 8091 | 9년 전 | 1130 | ||
| 8090 | 9년 전 | 740 | ||
| 8089 | 9년 전 | 943 | ||
| 8088 | 9년 전 | 617 | ||
| 8087 | 9년 전 | 727 | ||
| 8086 | 9년 전 | 494 | ||
| 8085 | 9년 전 | 462 | ||
| 8084 | 9년 전 | 601 | ||
| 8083 | 9년 전 | 570 | ||
| 8082 | 9년 전 | 740 | ||
| 8081 | 9년 전 | 453 | ||
| 8080 | 9년 전 | 538 | ||
| 8079 | 9년 전 | 493 | ||
| 8078 | 9년 전 | 423 | ||
| 8077 | 9년 전 | 500 | ||
| 8076 | 9년 전 | 385 | ||
| 8075 | 9년 전 | 402 | ||
| 8074 | 9년 전 | 372 | ||
| 8073 | 9년 전 | 420 | ||
| 8072 | 9년 전 | 408 | ||
| 8071 |
o1o111
|
9년 전 | 859 | |
| 8070 | 9년 전 | 378 | ||
| 8069 | 9년 전 | 306 | ||
| 8068 | 9년 전 | 570 | ||
| 8067 | 9년 전 | 377 | ||
| 8066 | 9년 전 | 405 | ||
| 8065 | 9년 전 | 353 | ||
| 8064 | 9년 전 | 337 | ||
| 8063 | 9년 전 | 300 | ||
| 8062 | 9년 전 | 287 | ||
| 8061 | 9년 전 | 334 | ||
| 8060 | 9년 전 | 354 | ||
| 8059 | 9년 전 | 293 | ||
| 8058 | 9년 전 | 228 | ||
| 8057 | 9년 전 | 358 | ||
| 8056 | 9년 전 | 286 | ||
| 8055 | 9년 전 | 318 | ||
| 8054 | 9년 전 | 334 | ||
| 8053 | 9년 전 | 378 | ||
| 8052 | 9년 전 | 261 | ||
| 8051 | 9년 전 | 305 | ||
| 8050 | 9년 전 | 371 | ||
| 8049 | 9년 전 | 297 | ||
| 8048 | 9년 전 | 406 | ||
| 8047 | 9년 전 | 337 | ||
| 8046 | 9년 전 | 265 | ||
| 8045 | 9년 전 | 239 | ||
| 8044 | 9년 전 | 305 | ||
| 8043 | 9년 전 | 250 | ||
| 8042 | 9년 전 | 269 | ||
| 8041 | 9년 전 | 311 | ||
| 8040 | 9년 전 | 240 | ||
| 8039 | 9년 전 | 300 | ||
| 8038 | 9년 전 | 251 | ||
| 8037 | 9년 전 | 368 | ||
| 8036 | 9년 전 | 454 | ||
| 8035 | 9년 전 | 406 | ||
| 8034 | 9년 전 | 368 | ||
| 8033 | 9년 전 | 325 | ||
| 8032 | 9년 전 | 382 | ||
| 8031 | 9년 전 | 314 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기