PHP array_splice()

1 개요[ | ]

  • 배열의 일부를 제거하거나 다른 것으로 교체하는 PHP 함수
$colors = ['red', 'green', 'blue', 'yellow'];
array_splice($colors, 2);
print_r($colors);
$colors = ['red', 'green', 'blue', 'yellow'];
array_splice($colors, 1, -1);
print_r($colors);
$colors = ['red', 'green', 'blue', 'yellow'];
array_splice($colors, 1, count($colors), 'orange');
print_r($colors);
$colors = ['red', 'green', 'blue', 'yellow'];
array_splice($colors, -1, 1, ['black', 'maroon']);
print_r($colors);

2 같이 보기[ | ]

3 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}