
array_shift 함수는 배열의 첫 번째 요소를 제거하고, 제거한 요소를 반환합니다.
예를 들어, $fruits = ['apple', 'banana', 'cherry'] 배열에서 'apple'을 제거하고 싶다면, array_shift 함수를 사용하면 됩니다.
#hostingforum.kr
php
$fruits = ['apple', 'banana', 'cherry'];
$firstFruit = array_shift($fruits);
print_r($fruits); // ['banana', 'cherry']가 출력됩니다.
print $firstFruit; // 'apple'이 출력됩니다.
array_shift 함수는 배열의 첫 번째 요소를 제거하고, 제거한 요소를 반환하기 때문에, $firstFruit 변수에 제거한 요소인 'apple'이 저장됩니다.
2025-07-21 21:54