PHP array_splice()

1 개요[ | ]

  • 배열의 일부를 제거하거나 다른 것으로 교체하는 PHP 함수
PHP
CPU
0.0s
MEM
21M
0.2s
Copy
$colors = ['red', 'green', 'blue', 'yellow'];
array_splice($colors, 2);
print_r($colors);
Array
(
    [0] => red
    [1] => green
)
PHP
Copy
$colors = ['red', 'green', 'blue', 'yellow'];
array_splice($colors, 1, -1);
print_r($colors);
Loading
PHP
Copy
$colors = ['red', 'green', 'blue', 'yellow'];
array_splice($colors, 1, count($colors), 'orange');
print_r($colors);
Loading
PHP
Copy
$colors = ['red', 'green', 'blue', 'yellow'];
array_splice($colors, -1, 1, ['black', 'maroon']);
print_r($colors);
Loading

2 같이 보기[ | ]

3 참고[ | ]