"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>
32번째 줄: 32번째 줄:
* https://www.php.net/manual/en/function.array-splice
* https://www.php.net/manual/en/function.array-splice


[[분류: PHP]]
[[분류: PHP 배열 함수]]

2021년 3월 19일 (금) 11:30 기준 최신판

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