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개
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 430 | 19년 전 | 4095 | ||
| 429 | 19년 전 | 3293 | ||
| 428 | 19년 전 | 4131 | ||
| 427 | 19년 전 | 3466 | ||
| 426 | 19년 전 | 3099 | ||
| 425 | 19년 전 | 3397 | ||
| 424 | 19년 전 | 2438 | ||
| 423 | 19년 전 | 2858 | ||
| 422 | 19년 전 | 2344 | ||
| 421 | 19년 전 | 3704 | ||
| 420 | 19년 전 | 4732 | ||
| 419 | 19년 전 | 3790 | ||
| 418 |
|
19년 전 | 1737 | |
| 417 | 19년 전 | 2741 | ||
| 416 | 19년 전 | 2387 | ||
| 415 | 19년 전 | 2605 | ||
| 414 | 19년 전 | 4404 | ||
| 413 |
|
19년 전 | 2593 | |
| 412 | 19년 전 | 3042 | ||
| 411 |
|
19년 전 | 2988 | |
| 410 |
|
19년 전 | 3677 | |
| 409 |
|
19년 전 | 3631 | |
| 408 |
|
19년 전 | 1849 | |
| 407 | 19년 전 | 2225 | ||
| 406 | 19년 전 | 2779 | ||
| 405 | 19년 전 | 2440 | ||
| 404 | 19년 전 | 4296 | ||
| 403 | 19년 전 | 3299 | ||
| 402 |
NeoGenesis
|
19년 전 | 4088 | |
| 401 | 19년 전 | 2603 | ||
| 400 |
|
19년 전 | 2488 | |
| 399 | 19년 전 | 2950 | ||
| 398 | 19년 전 | 2481 | ||
| 397 | 19년 전 | 2777 | ||
| 396 | 19년 전 | 2470 | ||
| 395 | 19년 전 | 3175 | ||
| 394 | 19년 전 | 1712 | ||
| 393 | 19년 전 | 2988 | ||
| 392 | 19년 전 | 2247 | ||
| 391 | 19년 전 | 2174 | ||
| 390 | 19년 전 | 2283 | ||
| 389 | 19년 전 | 2641 | ||
| 388 | 19년 전 | 2160 | ||
| 387 | 19년 전 | 4480 | ||
| 386 |
|
19년 전 | 2685 | |
| 385 |
|
19년 전 | 2477 | |
| 384 | 19년 전 | 3003 | ||
| 383 | 19년 전 | 3046 | ||
| 382 | 19년 전 | 3100 | ||
| 381 |
|
19년 전 | 2627 | |
| 380 |
|
19년 전 | 3012 | |
| 379 | 19년 전 | 2543 | ||
| 378 | 19년 전 | 2202 | ||
| 377 | 19년 전 | 2775 | ||
| 376 | 19년 전 | 2466 | ||
| 375 |
|
19년 전 | 2553 | |
| 374 | 19년 전 | 3811 | ||
| 373 | 19년 전 | 3263 | ||
| 372 | 19년 전 | 4984 | ||
| 371 |
세은아빠2
|
19년 전 | 2409 | |
| 370 | 19년 전 | 4495 | ||
| 369 | 19년 전 | 3107 | ||
| 368 | 19년 전 | 2891 | ||
| 367 | 19년 전 | 3721 | ||
| 366 | 19년 전 | 2644 | ||
| 365 | 19년 전 | 3732 | ||
| 364 | 19년 전 | 4008 | ||
| 363 | 19년 전 | 3433 | ||
| 362 | 19년 전 | 3474 | ||
| 361 | 19년 전 | 4103 | ||
| 360 |
hwatta
|
19년 전 | 2356 | |
| 359 | 19년 전 | 5097 | ||
| 358 | 19년 전 | 3653 | ||
| 357 | 19년 전 | 2593 | ||
| 356 |
sdesign1s
|
19년 전 | 2273 | |
| 355 | 20년 전 | 2742 | ||
| 354 | 20년 전 | 3026 | ||
| 353 | 20년 전 | 2786 | ||
| 352 |
|
20년 전 | 5768 | |
| 351 |
|
20년 전 | 2698 | |
| 350 |
|
20년 전 | 4285 | |
| 349 |
hwatta
|
20년 전 | 2179 | |
| 348 | 20년 전 | 7306 | ||
| 347 | 20년 전 | 2411 | ||
| 346 | 20년 전 | 3498 | ||
| 345 | 20년 전 | 4304 | ||
| 344 | 20년 전 | 2636 | ||
| 343 | 20년 전 | 3917 | ||
| 342 | 20년 전 | 3063 | ||
| 341 | 20년 전 | 4082 | ||
| 340 |
|
20년 전 | 5130 | |
| 339 |
|
20년 전 | 4230 | |
| 338 | 20년 전 | 5863 | ||
| 337 | 20년 전 | 2037 | ||
| 336 |
|
20년 전 | 3313 | |
| 335 |
|
20년 전 | 3534 | |
| 334 |
|
20년 전 | 2917 | |
| 333 |
hwatta
|
20년 전 | 2428 | |
| 332 | 20년 전 | 4651 | ||
| 331 | 20년 전 | 2265 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기