php 배열에 내용 추가하기
페이지 정보
작성자
본문
array_push 를 이용하여 기존 배열 $fruits 에 추가된 값들을 넣을 수 있습니다.
apple, banner, orange 에 melon 과 grape 를 새로 추가해서 밀어 넣습니다.
순서는 맨 뒤쪽으로 들어가게 됩니다.
$fruits = ['apple', 'banana', 'orange'];
array_push($fruits, 'melon', 'grape');
print_r($fruits);
// Array ( [0] => apple [1] => banana [2] => orange [3] => melon [4] => grape )
댓글목록
등록된 댓글이 없습니다.