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개
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 630 | 19년 전 | 2344 | ||
| 629 |
|
19년 전 | 2005 | |
| 628 |
|
19년 전 | 3119 | |
| 627 |
|
19년 전 | 2026 | |
| 626 |
|
19년 전 | 2066 | |
| 625 |
|
19년 전 | 1717 | |
| 624 |
|
19년 전 | 2217 | |
| 623 | 19년 전 | 2192 | ||
| 622 |
|
19년 전 | 2506 | |
| 621 |
|
19년 전 | 2903 | |
| 620 |
|
19년 전 | 2401 | |
| 619 | 19년 전 | 2463 | ||
| 618 | 19년 전 | 3510 | ||
| 617 |
|
19년 전 | 3230 | |
| 616 |
|
19년 전 | 3218 | |
| 615 |
|
19년 전 | 3034 | |
| 614 |
|
19년 전 | 2042 | |
| 613 |
|
19년 전 | 2371 | |
| 612 |
|
19년 전 | 2235 | |
| 611 |
|
19년 전 | 2080 | |
| 610 |
|
19년 전 | 2514 | |
| 609 |
|
19년 전 | 2418 | |
| 608 |
|
19년 전 | 2807 | |
| 607 | 19년 전 | 2190 | ||
| 606 | 19년 전 | 3522 | ||
| 605 | 19년 전 | 1985 | ||
| 604 | 19년 전 | 2589 | ||
| 603 | 19년 전 | 1606 | ||
| 602 |
|
19년 전 | 2831 | |
| 601 | 19년 전 | 3072 | ||
| 600 |
|
19년 전 | 2153 | |
| 599 | 19년 전 | 1993 | ||
| 598 | 19년 전 | 2476 | ||
| 597 | 19년 전 | 2387 | ||
| 596 |
|
19년 전 | 3072 | |
| 595 |
|
19년 전 | 6750 | |
| 594 | 19년 전 | 2705 | ||
| 593 | 19년 전 | 3184 | ||
| 592 |
|
19년 전 | 3086 | |
| 591 |
|
19년 전 | 1926 | |
| 590 | 19년 전 | 3363 | ||
| 589 | 19년 전 | 2205 | ||
| 588 |
|
19년 전 | 2704 | |
| 587 | 19년 전 | 2343 | ||
| 586 |
|
19년 전 | 4357 | |
| 585 | 19년 전 | 2485 | ||
| 584 | 19년 전 | 2752 | ||
| 583 |
|
19년 전 | 3520 | |
| 582 |
|
19년 전 | 3717 | |
| 581 |
|
19년 전 | 3248 | |
| 580 | 19년 전 | 2482 | ||
| 579 | 19년 전 | 3069 | ||
| 578 | 19년 전 | 3962 | ||
| 577 | 19년 전 | 3804 | ||
| 576 | 19년 전 | 1740 | ||
| 575 |
|
19년 전 | 2202 | |
| 574 |
|
19년 전 | 5400 | |
| 573 | 19년 전 | 6711 | ||
| 572 | 19년 전 | 2559 | ||
| 571 | 19년 전 | 2103 | ||
| 570 | 19년 전 | 2601 | ||
| 569 | 19년 전 | 3299 | ||
| 568 | 19년 전 | 3522 | ||
| 567 | 19년 전 | 2981 | ||
| 566 | 19년 전 | 2597 | ||
| 565 |
|
19년 전 | 4714 | |
| 564 |
|
19년 전 | 6726 | |
| 563 |
|
19년 전 | 4994 | |
| 562 |
|
19년 전 | 5945 | |
| 561 |
|
19년 전 | 2690 | |
| 560 |
|
19년 전 | 2534 | |
| 559 |
|
19년 전 | 2220 | |
| 558 |
|
19년 전 | 2297 | |
| 557 | 19년 전 | 4592 | ||
| 556 |
|
19년 전 | 4665 | |
| 555 | 19년 전 | 2501 | ||
| 554 | 19년 전 | 2172 | ||
| 553 | 19년 전 | 2519 | ||
| 552 |
|
19년 전 | 3156 | |
| 551 | 19년 전 | 2936 | ||
| 550 |
|
19년 전 | 1892 | |
| 549 |
|
19년 전 | 1952 | |
| 548 |
|
19년 전 | 3141 | |
| 547 |
|
19년 전 | 2355 | |
| 546 |
|
19년 전 | 3612 | |
| 545 |
|
19년 전 | 2541 | |
| 544 |
|
19년 전 | 1847 | |
| 543 |
|
19년 전 | 2452 | |
| 542 |
|
19년 전 | 1723 | |
| 541 |
|
19년 전 | 1404 | |
| 540 |
|
19년 전 | 1531 | |
| 539 |
|
19년 전 | 1797 | |
| 538 |
|
19년 전 | 1580 | |
| 537 |
|
19년 전 | 1777 | |
| 536 |
|
19년 전 | 1560 | |
| 535 |
|
19년 전 | 1958 | |
| 534 |
|
19년 전 | 1843 | |
| 533 |
|
19년 전 | 1443 | |
| 532 |
|
19년 전 | 1441 | |
| 531 |
|
19년 전 | 1353 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기