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개
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 7630 | 10년 전 | 652 | ||
| 7629 |
|
10년 전 | 2387 | |
| 7628 | 10년 전 | 791 | ||
| 7627 |
|
10년 전 | 1030 | |
| 7626 |
|
10년 전 | 1787 | |
| 7625 | 10년 전 | 707 | ||
| 7624 | 10년 전 | 724 | ||
| 7623 |
|
10년 전 | 3089 | |
| 7622 | 10년 전 | 725 | ||
| 7621 |
leeleeleelee
|
10년 전 | 585 | |
| 7620 | 10년 전 | 540 | ||
| 7619 | 10년 전 | 488 | ||
| 7618 | 10년 전 | 1024 | ||
| 7617 | 10년 전 | 726 | ||
| 7616 | 10년 전 | 645 | ||
| 7615 | 10년 전 | 726 | ||
| 7614 | 10년 전 | 1263 | ||
| 7613 |
|
10년 전 | 2085 | |
| 7612 | 10년 전 | 1143 | ||
| 7611 | 10년 전 | 1416 | ||
| 7610 |
|
10년 전 | 1901 | |
| 7609 |
|
10년 전 | 1342 | |
| 7608 |
mwdkim
|
10년 전 | 1131 | |
| 7607 |
|
10년 전 | 1053 | |
| 7606 |
mwdkim
|
10년 전 | 3927 | |
| 7605 | 10년 전 | 691 | ||
| 7604 | 10년 전 | 1027 | ||
| 7603 | 10년 전 | 1651 | ||
| 7602 |
|
10년 전 | 1078 | |
| 7601 |
AniNest
|
10년 전 | 2791 | |
| 7600 |
port443
|
10년 전 | 1031 | |
| 7599 | 10년 전 | 944 | ||
| 7598 | 10년 전 | 1020 | ||
| 7597 | 10년 전 | 4572 | ||
| 7596 |
SeungYeon
|
10년 전 | 889 | |
| 7595 |
untitled
|
10년 전 | 2425 | |
| 7594 |
프로그래머7
|
10년 전 | 1725 | |
| 7593 |
untitled
|
10년 전 | 2365 | |
| 7592 |
untitled
|
10년 전 | 1941 | |
| 7591 |
untitled
|
10년 전 | 2676 | |
| 7590 |
아리마2001
|
10년 전 | 853 | |
| 7589 | 10년 전 | 1110 | ||
| 7588 |
|
10년 전 | 2919 | |
| 7587 | 10년 전 | 1303 | ||
| 7586 | 10년 전 | 672 | ||
| 7585 | 10년 전 | 1694 | ||
| 7584 | 10년 전 | 1414 | ||
| 7583 |
leeleeleelee
|
10년 전 | 1162 | |
| 7582 |
|
10년 전 | 1111 | |
| 7581 | 10년 전 | 1345 | ||
| 7580 | 10년 전 | 992 | ||
| 7579 |
|
10년 전 | 606 | |
| 7578 | 10년 전 | 1429 | ||
| 7577 |
|
10년 전 | 1872 | |
| 7576 | 10년 전 | 1385 | ||
| 7575 |
멋진남자임
|
10년 전 | 1463 | |
| 7574 | 10년 전 | 2122 | ||
| 7573 | 10년 전 | 3256 | ||
| 7572 | 10년 전 | 761 | ||
| 7571 |
|
10년 전 | 783 | |
| 7570 |
|
10년 전 | 1314 | |
| 7569 | 10년 전 | 1552 | ||
| 7568 |
this1mg
|
10년 전 | 1050 | |
| 7567 |
|
10년 전 | 762 | |
| 7566 | 10년 전 | 918 | ||
| 7565 |
Angel하늘
|
10년 전 | 1005 | |
| 7564 |
seoldi
|
10년 전 | 1238 | |
| 7563 |
|
10년 전 | 1381 | |
| 7562 |
멋진남자임
|
10년 전 | 2085 | |
| 7561 | 10년 전 | 714 | ||
| 7560 |
leeleeleelee
|
10년 전 | 903 | |
| 7559 | 10년 전 | 5047 | ||
| 7558 |
RinaP
|
10년 전 | 784 | |
| 7557 |
|
10년 전 | 1246 | |
| 7556 | 10년 전 | 1192 | ||
| 7555 |
hyohyojj1234
|
10년 전 | 1664 | |
| 7554 | 10년 전 | 1093 | ||
| 7553 |
senseme
|
10년 전 | 1338 | |
| 7552 |
ehdltdoit
|
10년 전 | 1436 | |
| 7551 |
|
10년 전 | 1824 | |
| 7550 |
leeleeleelee
|
10년 전 | 1589 | |
| 7549 | 10년 전 | 2425 | ||
| 7548 | 10년 전 | 1843 | ||
| 7547 |
멋진남자임
|
10년 전 | 1962 | |
| 7546 | 10년 전 | 1004 | ||
| 7545 |
ILMare1003
|
10년 전 | 1288 | |
| 7544 |
|
10년 전 | 1251 | |
| 7543 | 10년 전 | 884 | ||
| 7542 | 10년 전 | 657 | ||
| 7541 |
울라라라우
|
10년 전 | 865 | |
| 7540 | 10년 전 | 1600 | ||
| 7539 | 10년 전 | 935 | ||
| 7538 |
|
10년 전 | 1833 | |
| 7537 | 10년 전 | 3611 | ||
| 7536 |
Gaumi
|
10년 전 | 1416 | |
| 7535 |
프로그램은어려워
|
10년 전 | 1273 | |
| 7534 |
senseme
|
10년 전 | 1207 | |
| 7533 | 10년 전 | 1196 | ||
| 7532 | 10년 전 | 858 | ||
| 7531 | 10년 전 | 2053 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기