반응형
array_splice를 이용하여 원하는 만큼 배열을 자를 수 있습니다.
잘라서 없애는 것이 아닌 자른 것을 다시 배열에 넣는 것입니다.
<?php
$input = array("red", "green", "blue", "yellow");
array_splice($input, 2);
// $input is now array("red", "green")
$input = array("red", "green", "blue", "yellow");
array_splice($input, 1, -1);
// $input is now array("red", "yellow")
$input = array("red", "green", "blue", "yellow");
array_splice($input, 1, count($input), "orange");
// $input is now array("red", "orange")
$input = array("red", "green", "blue", "yellow");
array_splice($input, -1, 1, array("black", "maroon"));
// $input is now array("red", "green",
// "blue", "black", "maroon")
$input = array("red", "green", "blue", "yellow");
array_splice($input, 3, 0, "purple");
// $input is now array("red", "green",
// "blue", "purple", "yellow");
?>
2015/11/28 - [UFC] - UFC 서울 김동현 워터스 완벽한 승리 주요장면
2015/11/28 - [UFC] - UFC 서울 추성훈 알베르토 미나 판정패 추성훈 주요장면 말도안돼
2015/11/20 - [UFC] - 유승옥 UFC 서울 옥타곤걸 발탁
반응형
'IT > php' 카테고리의 다른 글
php 배열을 json으로 인코딩 디코딩하기 (0) | 2015.11.30 |
---|---|
php 엑셀 다운로드 상세페이지 쿼리 없이 실행 (0) | 2015.11.28 |
The mbstring extension is missing. Please check your PHP configuration. (0) | 2015.11.24 |
php multipart 사용법 stream_context_create (0) | 2015.11.23 |
php simplexml_load_string xml 파싱 (0) | 2015.11.22 |