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개
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 6930 |
SOFTA
|
11년 전 | 5984 | |
| 6929 |
|
11년 전 | 1594 | |
| 6928 | 11년 전 | 1756 | ||
| 6927 | 11년 전 | 1779 | ||
| 6926 | 11년 전 | 1884 | ||
| 6925 | 11년 전 | 2275 | ||
| 6924 | 11년 전 | 3874 | ||
| 6923 | 11년 전 | 2272 | ||
| 6922 |
level999
|
11년 전 | 1041 | |
| 6921 | 11년 전 | 821 | ||
| 6920 | 11년 전 | 954 | ||
| 6919 | 11년 전 | 1070 | ||
| 6918 | 11년 전 | 1311 | ||
| 6917 | 11년 전 | 15428 | ||
| 6916 | 11년 전 | 1426 | ||
| 6915 | 11년 전 | 586 | ||
| 6914 | 11년 전 | 615 | ||
| 6913 | 11년 전 | 880 | ||
| 6912 | 11년 전 | 3126 | ||
| 6911 |
사랑해요79
|
11년 전 | 965 | |
| 6910 | 11년 전 | 744 | ||
| 6909 | 11년 전 | 781 | ||
| 6908 | 11년 전 | 644 | ||
| 6907 | 11년 전 | 832 | ||
| 6906 | 11년 전 | 1587 | ||
| 6905 | 11년 전 | 569 | ||
| 6904 | 11년 전 | 1010 | ||
| 6903 | 11년 전 | 1676 | ||
| 6902 |
2donggalbi
|
11년 전 | 516 | |
| 6901 | 11년 전 | 1395 | ||
| 6900 | 11년 전 | 720 | ||
| 6899 | 11년 전 | 861 | ||
| 6898 |
열라뽕똬이
|
11년 전 | 1311 | |
| 6897 |
this1mg
|
11년 전 | 1610 | |
| 6896 |
sbdossb
|
11년 전 | 576 | |
| 6895 |
봉보로봉봉
|
11년 전 | 1154 | |
| 6894 |
똘똘이스머츠
|
11년 전 | 497 | |
| 6893 |
네이비컬러
|
11년 전 | 3639 | |
| 6892 | 11년 전 | 1076 | ||
| 6891 |
네이비컬러
|
11년 전 | 1319 | |
| 6890 | 11년 전 | 1140 | ||
| 6889 | 11년 전 | 588 | ||
| 6888 | 11년 전 | 724 | ||
| 6887 | 11년 전 | 615 | ||
| 6886 | 11년 전 | 5058 | ||
| 6885 | 11년 전 | 556 | ||
| 6884 |
asfasdfd235
|
11년 전 | 582 | |
| 6883 | 11년 전 | 3037 | ||
| 6882 | 11년 전 | 921 | ||
| 6881 | 11년 전 | 4429 | ||
| 6880 | 11년 전 | 1814 | ||
| 6879 |
퍼블리셔지노군
|
11년 전 | 2627 | |
| 6878 | 11년 전 | 558 | ||
| 6877 | 11년 전 | 580 | ||
| 6876 | 11년 전 | 1445 | ||
| 6875 | 11년 전 | 629 | ||
| 6874 | 11년 전 | 1603 | ||
| 6873 | 11년 전 | 1606 | ||
| 6872 | 11년 전 | 4460 | ||
| 6871 |
Abilityarch
|
11년 전 | 965 | |
| 6870 | 11년 전 | 2128 | ||
| 6869 | 11년 전 | 1410 | ||
| 6868 | 11년 전 | 1454 | ||
| 6867 | 11년 전 | 1526 | ||
| 6866 | 11년 전 | 743 | ||
| 6865 | 11년 전 | 1617 | ||
| 6864 | 11년 전 | 475 | ||
| 6863 | 11년 전 | 3751 | ||
| 6862 | 11년 전 | 1849 | ||
| 6861 | 11년 전 | 1647 | ||
| 6860 | 11년 전 | 1304 | ||
| 6859 |
cityman
|
11년 전 | 6814 | |
| 6858 | 11년 전 | 1270 | ||
| 6857 |
의정부아줌마
|
11년 전 | 869 | |
| 6856 | 11년 전 | 2374 | ||
| 6855 | 11년 전 | 1700 | ||
| 6854 | 11년 전 | 829 | ||
| 6853 | 11년 전 | 1210 | ||
| 6852 | 11년 전 | 2598 | ||
| 6851 | 11년 전 | 1974 | ||
| 6850 | 11년 전 | 1794 | ||
| 6849 | 11년 전 | 2085 | ||
| 6848 | 11년 전 | 2365 | ||
| 6847 | 11년 전 | 3142 | ||
| 6846 | 11년 전 | 2720 | ||
| 6845 | 11년 전 | 2800 | ||
| 6844 | 11년 전 | 3523 | ||
| 6843 | 11년 전 | 3265 | ||
| 6842 |
아트291
|
11년 전 | 694 | |
| 6841 | 11년 전 | 4171 | ||
| 6840 | 11년 전 | 5187 | ||
| 6839 | 11년 전 | 894 | ||
| 6838 |
|
11년 전 | 2097 | |
| 6837 | 11년 전 | 1278 | ||
| 6836 |
netdf
|
11년 전 | 613 | |
| 6835 |
|
11년 전 | 1011 | |
| 6834 | 11년 전 | 674 | ||
| 6833 |
|
11년 전 | 2687 | |
| 6832 |
울산굿모닝
|
11년 전 | 1663 | |
| 6831 |
|
11년 전 | 670 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기