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개
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 930 | 19년 전 | 3554 | ||
| 929 |
|
19년 전 | 2722 | |
| 928 |
|
19년 전 | 3462 | |
| 927 |
|
19년 전 | 3453 | |
| 926 |
|
19년 전 | 3155 | |
| 925 | 19년 전 | 5443 | ||
| 924 |
|
19년 전 | 2183 | |
| 923 |
|
19년 전 | 2244 | |
| 922 |
|
19년 전 | 2328 | |
| 921 |
|
19년 전 | 3421 | |
| 920 | 19년 전 | 3718 | ||
| 919 |
|
19년 전 | 3756 | |
| 918 |
|
19년 전 | 2382 | |
| 917 |
|
19년 전 | 2409 | |
| 916 |
|
19년 전 | 2720 | |
| 915 | 19년 전 | 3065 | ||
| 914 | 19년 전 | 2472 | ||
| 913 | 19년 전 | 2635 | ||
| 912 | 19년 전 | 2465 | ||
| 911 | 19년 전 | 2233 | ||
| 910 | 19년 전 | 3260 | ||
| 909 | 19년 전 | 3324 | ||
| 908 | 19년 전 | 3056 | ||
| 907 |
|
19년 전 | 4881 | |
| 906 |
|
19년 전 | 2723 | |
| 905 |
|
19년 전 | 3323 | |
| 904 |
|
19년 전 | 3165 | |
| 903 |
|
19년 전 | 2007 | |
| 902 |
|
19년 전 | 3163 | |
| 901 |
|
19년 전 | 1895 | |
| 900 |
|
19년 전 | 2352 | |
| 899 |
|
19년 전 | 2411 | |
| 898 |
|
19년 전 | 4000 | |
| 897 |
|
19년 전 | 3204 | |
| 896 |
|
19년 전 | 3116 | |
| 895 |
|
19년 전 | 2553 | |
| 894 |
|
19년 전 | 2030 | |
| 893 |
|
19년 전 | 1663 | |
| 892 |
|
19년 전 | 2428 | |
| 891 |
|
19년 전 | 2339 | |
| 890 |
|
19년 전 | 1823 | |
| 889 |
|
19년 전 | 1826 | |
| 888 |
|
19년 전 | 2619 | |
| 887 |
|
19년 전 | 2588 | |
| 886 |
|
19년 전 | 1880 | |
| 885 |
|
19년 전 | 2130 | |
| 884 |
|
19년 전 | 3317 | |
| 883 |
|
19년 전 | 1963 | |
| 882 |
|
19년 전 | 2516 | |
| 881 |
|
19년 전 | 2598 | |
| 880 |
|
19년 전 | 2675 | |
| 879 |
|
19년 전 | 2947 | |
| 878 |
|
19년 전 | 2569 | |
| 877 |
|
19년 전 | 2991 | |
| 876 |
|
19년 전 | 2767 | |
| 875 |
|
19년 전 | 3527 | |
| 874 | 19년 전 | 1880 | ||
| 873 | 19년 전 | 2748 | ||
| 872 |
|
19년 전 | 2385 | |
| 871 |
|
19년 전 | 2030 | |
| 870 |
|
19년 전 | 2434 | |
| 869 |
|
19년 전 | 1880 | |
| 868 |
|
19년 전 | 5451 | |
| 867 |
|
19년 전 | 2277 | |
| 866 |
|
19년 전 | 4280 | |
| 865 |
|
19년 전 | 2315 | |
| 864 | 19년 전 | 1868 | ||
| 863 | 19년 전 | 2623 | ||
| 862 | 19년 전 | 2341 | ||
| 861 | 19년 전 | 2540 | ||
| 860 | 19년 전 | 2179 | ||
| 859 | 19년 전 | 3931 | ||
| 858 | 19년 전 | 3430 | ||
| 857 | 19년 전 | 2214 | ||
| 856 |
Power
|
19년 전 | 2113 | |
| 855 | 19년 전 | 1979 | ||
| 854 | 19년 전 | 2012 | ||
| 853 |
pearly
|
19년 전 | 4416 | |
| 852 |
pearly
|
19년 전 | 3366 | |
| 851 | 19년 전 | 2787 | ||
| 850 |
pearly
|
19년 전 | 3361 | |
| 849 |
pearly
|
19년 전 | 3019 | |
| 848 |
pearly
|
19년 전 | 2858 | |
| 847 | 19년 전 | 2379 | ||
| 846 |
|
19년 전 | 2190 | |
| 845 |
pearly
|
19년 전 | 2509 | |
| 844 | 19년 전 | 3117 | ||
| 843 | 19년 전 | 2146 | ||
| 842 |
pearly
|
19년 전 | 3132 | |
| 841 |
pearly
|
19년 전 | 3256 | |
| 840 | 19년 전 | 2940 | ||
| 839 |
|
19년 전 | 1954 | |
| 838 |
|
19년 전 | 1718 | |
| 837 |
|
19년 전 | 2341 | |
| 836 |
|
19년 전 | 2290 | |
| 835 |
|
19년 전 | 1663 | |
| 834 |
|
19년 전 | 1677 | |
| 833 |
|
19년 전 | 1583 | |
| 832 |
|
19년 전 | 2074 | |
| 831 |
|
19년 전 | 1625 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기