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개
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 6830 |
112211dd
|
11년 전 | 792 | |
| 6829 |
진짜다진짜가나타남
|
11년 전 | 1207 | |
| 6828 | 11년 전 | 822 | ||
| 6827 |
봉보로봉봉
|
11년 전 | 914 | |
| 6826 |
jinion
|
11년 전 | 824 | |
| 6825 | 11년 전 | 804 | ||
| 6824 |
yunkiri486
|
11년 전 | 725 | |
| 6823 |
2donggalbi
|
11년 전 | 852 | |
| 6822 | 11년 전 | 851 | ||
| 6821 | 11년 전 | 803 | ||
| 6820 | 11년 전 | 3106 | ||
| 6819 | 11년 전 | 1252 | ||
| 6818 | 11년 전 | 518 | ||
| 6817 |
|
11년 전 | 610 | |
| 6816 | 11년 전 | 2080 | ||
| 6815 | 11년 전 | 1215 | ||
| 6814 | 11년 전 | 866 | ||
| 6813 | 11년 전 | 609 | ||
| 6812 |
|
11년 전 | 985 | |
| 6811 | 11년 전 | 585 | ||
| 6810 | 11년 전 | 1536 | ||
| 6809 |
낚시가좋아
|
11년 전 | 1047 | |
| 6808 | 11년 전 | 442 | ||
| 6807 | 11년 전 | 764 | ||
| 6806 |
Unhappy
|
11년 전 | 1775 | |
| 6805 | 11년 전 | 1606 | ||
| 6804 | 11년 전 | 1126 | ||
| 6803 | 11년 전 | 567 | ||
| 6802 |
asdfg
|
11년 전 | 1135 | |
| 6801 |
아트귀농인
|
11년 전 | 503 | |
| 6800 | 11년 전 | 2556 | ||
| 6799 | 11년 전 | 1357 | ||
| 6798 | 11년 전 | 1466 | ||
| 6797 | 11년 전 | 627 | ||
| 6796 |
purple63
|
11년 전 | 431 | |
| 6795 | 11년 전 | 2638 | ||
| 6794 |
커네드커네드
|
11년 전 | 963 | |
| 6793 | 11년 전 | 409 | ||
| 6792 | 11년 전 | 2500 | ||
| 6791 | 11년 전 | 527 | ||
| 6790 | 11년 전 | 2259 | ||
| 6789 |
리아빌리티
|
11년 전 | 3098 | |
| 6788 | 11년 전 | 1345 | ||
| 6787 | 11년 전 | 680 | ||
| 6786 | 11년 전 | 392 | ||
| 6785 | 11년 전 | 721 | ||
| 6784 |
|
11년 전 | 849 | |
| 6783 | 11년 전 | 585 | ||
| 6782 | 11년 전 | 3657 | ||
| 6781 |
리아빌리티
|
11년 전 | 487 | |
| 6780 | 11년 전 | 532 | ||
| 6779 | 11년 전 | 484 | ||
| 6778 | 11년 전 | 4693 | ||
| 6777 |
바보온달123
|
11년 전 | 618 | |
| 6776 | 11년 전 | 931 | ||
| 6775 | 11년 전 | 732 | ||
| 6774 |
DANet
|
11년 전 | 641 | |
| 6773 | 11년 전 | 1559 | ||
| 6772 | 11년 전 | 1356 | ||
| 6771 | 11년 전 | 619 | ||
| 6770 | 11년 전 | 1160 | ||
| 6769 | 11년 전 | 955 | ||
| 6768 | 11년 전 | 691 | ||
| 6767 | 11년 전 | 584 | ||
| 6766 | 11년 전 | 1264 | ||
| 6765 |
크림나이트
|
11년 전 | 1000 | |
| 6764 | 11년 전 | 1549 | ||
| 6763 | 11년 전 | 2603 | ||
| 6762 | 11년 전 | 537 | ||
| 6761 |
|
11년 전 | 783 | |
| 6760 |
|
11년 전 | 712 | |
| 6759 | 11년 전 | 3352 | ||
| 6758 | 11년 전 | 1007 | ||
| 6757 | 11년 전 | 1269 | ||
| 6756 | 11년 전 | 892 | ||
| 6755 |
|
11년 전 | 568 | |
| 6754 |
|
11년 전 | 714 | |
| 6753 |
|
11년 전 | 1386 | |
| 6752 | 11년 전 | 608 | ||
| 6751 |
|
11년 전 | 653 | |
| 6750 |
|
11년 전 | 2021 | |
| 6749 | 11년 전 | 1216 | ||
| 6748 |
|
11년 전 | 1118 | |
| 6747 | 11년 전 | 1170 | ||
| 6746 | 11년 전 | 840 | ||
| 6745 |
|
11년 전 | 911 | |
| 6744 | 11년 전 | 851 | ||
| 6743 | 11년 전 | 1291 | ||
| 6742 | 11년 전 | 541 | ||
| 6741 |
Abilityarch
|
11년 전 | 611 | |
| 6740 | 11년 전 | 655 | ||
| 6739 |
leewin20
|
11년 전 | 1235 | |
| 6738 | 11년 전 | 507 | ||
| 6737 | 11년 전 | 1219 | ||
| 6736 | 11년 전 | 1258 | ||
| 6735 | 11년 전 | 547 | ||
| 6734 | 11년 전 | 1284 | ||
| 6733 |
RipperTNT
|
11년 전 | 1840 | |
| 6732 |
|
11년 전 | 1337 | |
| 6731 |
|
11년 전 | 1395 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기