"PHP array splice()"의 두 판 사이의 차이

(새 문서: ==개요== {{DISPLAYTITLE:PHP array_splice()}} * 배열의 일부를 제거하거나 다른 것으로 교체하는 PHP 함수 <syntaxhighlight lang='php' run> $colors = ['red', 'gree...)
 
15번째 줄: 15번째 줄:
<syntaxhighlight lang='php' run>
<syntaxhighlight lang='php' run>
$colors = ['red', 'green', 'blue', 'yellow'];
$colors = ['red', 'green', 'blue', 'yellow'];
array_splice($colors, 1, count($arr), 'orange');
array_splice($colors, 1, count($colors), 'orange');
print_r($colors);
print_r($colors);
</syntaxhighlight>
</syntaxhighlight>

2021년 3월 19일 (금) 11:28 판

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 }}