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년 전 | 671 | ||
| 7629 |
|
10년 전 | 2424 | |
| 7628 | 10년 전 | 808 | ||
| 7627 |
|
10년 전 | 1046 | |
| 7626 |
|
10년 전 | 1802 | |
| 7625 | 10년 전 | 733 | ||
| 7624 | 10년 전 | 748 | ||
| 7623 |
|
10년 전 | 3124 | |
| 7622 | 10년 전 | 747 | ||
| 7621 |
leeleeleelee
|
10년 전 | 603 | |
| 7620 | 10년 전 | 550 | ||
| 7619 | 10년 전 | 513 | ||
| 7618 | 10년 전 | 1050 | ||
| 7617 | 10년 전 | 737 | ||
| 7616 | 10년 전 | 671 | ||
| 7615 | 10년 전 | 740 | ||
| 7614 | 10년 전 | 1281 | ||
| 7613 |
|
10년 전 | 2095 | |
| 7612 | 10년 전 | 1177 | ||
| 7611 | 10년 전 | 1438 | ||
| 7610 |
|
10년 전 | 1916 | |
| 7609 |
|
10년 전 | 1371 | |
| 7608 |
mwdkim
|
10년 전 | 1148 | |
| 7607 |
|
10년 전 | 1079 | |
| 7606 |
mwdkim
|
10년 전 | 3954 | |
| 7605 | 10년 전 | 704 | ||
| 7604 | 10년 전 | 1041 | ||
| 7603 | 10년 전 | 1663 | ||
| 7602 |
|
10년 전 | 1095 | |
| 7601 |
AniNest
|
10년 전 | 2810 | |
| 7600 |
port443
|
10년 전 | 1052 | |
| 7599 | 10년 전 | 957 | ||
| 7598 | 10년 전 | 1038 | ||
| 7597 | 10년 전 | 4589 | ||
| 7596 |
SeungYeon
|
10년 전 | 908 | |
| 7595 |
untitled
|
10년 전 | 2451 | |
| 7594 |
프로그래머7
|
10년 전 | 1747 | |
| 7593 |
untitled
|
10년 전 | 2387 | |
| 7592 |
untitled
|
10년 전 | 1957 | |
| 7591 |
untitled
|
10년 전 | 2693 | |
| 7590 |
아리마2001
|
10년 전 | 869 | |
| 7589 | 10년 전 | 1121 | ||
| 7588 |
|
10년 전 | 2938 | |
| 7587 | 10년 전 | 1319 | ||
| 7586 | 10년 전 | 685 | ||
| 7585 | 10년 전 | 1720 | ||
| 7584 | 10년 전 | 1423 | ||
| 7583 |
leeleeleelee
|
10년 전 | 1188 | |
| 7582 |
|
10년 전 | 1148 | |
| 7581 | 10년 전 | 1376 | ||
| 7580 | 10년 전 | 1028 | ||
| 7579 |
|
10년 전 | 618 | |
| 7578 | 10년 전 | 1440 | ||
| 7577 |
|
10년 전 | 1887 | |
| 7576 | 10년 전 | 1400 | ||
| 7575 |
멋진남자임
|
10년 전 | 1481 | |
| 7574 | 10년 전 | 2140 | ||
| 7573 | 10년 전 | 3276 | ||
| 7572 | 10년 전 | 776 | ||
| 7571 |
|
10년 전 | 796 | |
| 7570 |
|
10년 전 | 1337 | |
| 7569 | 10년 전 | 1565 | ||
| 7568 |
this1mg
|
10년 전 | 1064 | |
| 7567 |
|
10년 전 | 781 | |
| 7566 | 10년 전 | 929 | ||
| 7565 |
Angel하늘
|
10년 전 | 1031 | |
| 7564 |
seoldi
|
10년 전 | 1275 | |
| 7563 |
|
10년 전 | 1415 | |
| 7562 |
멋진남자임
|
10년 전 | 2112 | |
| 7561 | 10년 전 | 731 | ||
| 7560 |
leeleeleelee
|
10년 전 | 929 | |
| 7559 | 10년 전 | 5069 | ||
| 7558 |
RinaP
|
10년 전 | 808 | |
| 7557 |
|
10년 전 | 1271 | |
| 7556 | 10년 전 | 1210 | ||
| 7555 |
hyohyojj1234
|
10년 전 | 1679 | |
| 7554 | 10년 전 | 1107 | ||
| 7553 |
senseme
|
10년 전 | 1357 | |
| 7552 |
ehdltdoit
|
10년 전 | 1455 | |
| 7551 |
|
10년 전 | 1846 | |
| 7550 |
leeleeleelee
|
10년 전 | 1614 | |
| 7549 | 10년 전 | 2447 | ||
| 7548 | 10년 전 | 1856 | ||
| 7547 |
멋진남자임
|
10년 전 | 1974 | |
| 7546 | 10년 전 | 1020 | ||
| 7545 |
ILMare1003
|
10년 전 | 1311 | |
| 7544 |
|
10년 전 | 1266 | |
| 7543 | 10년 전 | 901 | ||
| 7542 | 10년 전 | 681 | ||
| 7541 |
울라라라우
|
10년 전 | 878 | |
| 7540 | 10년 전 | 1608 | ||
| 7539 | 10년 전 | 954 | ||
| 7538 |
|
10년 전 | 1843 | |
| 7537 | 10년 전 | 3629 | ||
| 7536 |
Gaumi
|
10년 전 | 1436 | |
| 7535 |
프로그램은어려워
|
10년 전 | 1292 | |
| 7534 |
senseme
|
10년 전 | 1217 | |
| 7533 | 10년 전 | 1221 | ||
| 7532 | 10년 전 | 886 | ||
| 7531 | 10년 전 | 2074 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기