PHP 배열 관련 함수 모음

array_merge()

  • array 합치기
  • array_merge는 순서대로 key를 맞추어 정렬
$arrA = ['0' => 1, '2' => 2];
$arrB = ['0' => 3, '2' => 4];
$arr = array_merge($arrA, $arrB);
  • result
(
[0] => 1
[1] => 2
[2] => 3
[3] => 4
)

in_array()

  • array 안에 value값 있는지 체크
  • in_array(“체크하려는 값”, $arr)
$os = array("Mac", "NT", "Irix", "Linux");

if (in_array("Irix", $os)) {
    echo "Got Irix";
} 

Published by

shotan

Hi i'm cho

Leave a Reply

Your email address will not be published. Required fields are marked *