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년 전 | 4094 | ||
| 429 | 19년 전 | 3290 | ||
| 428 | 19년 전 | 4130 | ||
| 427 | 19년 전 | 3465 | ||
| 426 | 19년 전 | 3099 | ||
| 425 | 19년 전 | 3395 | ||
| 424 | 19년 전 | 2437 | ||
| 423 | 19년 전 | 2855 | ||
| 422 | 19년 전 | 2344 | ||
| 421 | 19년 전 | 3703 | ||
| 420 | 19년 전 | 4730 | ||
| 419 | 19년 전 | 3786 | ||
| 418 |
|
19년 전 | 1736 | |
| 417 | 19년 전 | 2740 | ||
| 416 | 19년 전 | 2387 | ||
| 415 | 19년 전 | 2603 | ||
| 414 | 19년 전 | 4402 | ||
| 413 |
|
19년 전 | 2589 | |
| 412 | 19년 전 | 3038 | ||
| 411 |
|
19년 전 | 2985 | |
| 410 |
|
19년 전 | 3675 | |
| 409 |
|
19년 전 | 3631 | |
| 408 |
|
19년 전 | 1848 | |
| 407 | 19년 전 | 2223 | ||
| 406 | 19년 전 | 2776 | ||
| 405 | 19년 전 | 2438 | ||
| 404 | 19년 전 | 4293 | ||
| 403 | 19년 전 | 3299 | ||
| 402 |
NeoGenesis
|
19년 전 | 4087 | |
| 401 | 19년 전 | 2602 | ||
| 400 |
|
19년 전 | 2486 | |
| 399 | 19년 전 | 2948 | ||
| 398 | 19년 전 | 2481 | ||
| 397 | 19년 전 | 2777 | ||
| 396 | 19년 전 | 2467 | ||
| 395 | 19년 전 | 3174 | ||
| 394 | 19년 전 | 1710 | ||
| 393 | 19년 전 | 2988 | ||
| 392 | 19년 전 | 2244 | ||
| 391 | 19년 전 | 2174 | ||
| 390 | 19년 전 | 2278 | ||
| 389 | 19년 전 | 2640 | ||
| 388 | 19년 전 | 2153 | ||
| 387 | 19년 전 | 4478 | ||
| 386 |
|
19년 전 | 2682 | |
| 385 |
|
19년 전 | 2475 | |
| 384 | 19년 전 | 3000 | ||
| 383 | 19년 전 | 3044 | ||
| 382 | 19년 전 | 3100 | ||
| 381 |
|
19년 전 | 2627 | |
| 380 |
|
19년 전 | 3011 | |
| 379 | 19년 전 | 2542 | ||
| 378 | 19년 전 | 2201 | ||
| 377 | 19년 전 | 2775 | ||
| 376 | 19년 전 | 2465 | ||
| 375 |
|
19년 전 | 2552 | |
| 374 | 19년 전 | 3807 | ||
| 373 | 19년 전 | 3261 | ||
| 372 | 19년 전 | 4984 | ||
| 371 |
세은아빠2
|
19년 전 | 2409 | |
| 370 | 19년 전 | 4495 | ||
| 369 | 19년 전 | 3104 | ||
| 368 | 19년 전 | 2889 | ||
| 367 | 19년 전 | 3721 | ||
| 366 | 19년 전 | 2642 | ||
| 365 | 19년 전 | 3728 | ||
| 364 | 19년 전 | 4005 | ||
| 363 | 19년 전 | 3428 | ||
| 362 | 19년 전 | 3472 | ||
| 361 | 19년 전 | 4100 | ||
| 360 |
hwatta
|
19년 전 | 2354 | |
| 359 | 19년 전 | 5096 | ||
| 358 | 19년 전 | 3651 | ||
| 357 | 19년 전 | 2590 | ||
| 356 |
sdesign1s
|
19년 전 | 2271 | |
| 355 | 20년 전 | 2742 | ||
| 354 | 20년 전 | 3025 | ||
| 353 | 20년 전 | 2785 | ||
| 352 |
|
20년 전 | 5766 | |
| 351 |
|
20년 전 | 2697 | |
| 350 |
|
20년 전 | 4284 | |
| 349 |
hwatta
|
20년 전 | 2178 | |
| 348 | 20년 전 | 7305 | ||
| 347 | 20년 전 | 2409 | ||
| 346 | 20년 전 | 3494 | ||
| 345 | 20년 전 | 4303 | ||
| 344 | 20년 전 | 2630 | ||
| 343 | 20년 전 | 3916 | ||
| 342 | 20년 전 | 3061 | ||
| 341 | 20년 전 | 4082 | ||
| 340 |
|
20년 전 | 5128 | |
| 339 |
|
20년 전 | 4226 | |
| 338 | 20년 전 | 5861 | ||
| 337 | 20년 전 | 2034 | ||
| 336 |
|
20년 전 | 3306 | |
| 335 |
|
20년 전 | 3532 | |
| 334 |
|
20년 전 | 2915 | |
| 333 |
hwatta
|
20년 전 | 2425 | |
| 332 | 20년 전 | 4651 | ||
| 331 | 20년 전 | 2263 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기