PHP array replace()

Jmnote (토론 | 기여)님의 2016년 2월 1일 (월) 13:03 판 (새 문서: ==개요== <source lang='PHP'> $base = array("orange", "banana", "apple", "raspberry"); $replacements = array(0 => "pineapple", 4 => "cherry"); $replacements2 = array(0 => "grape");...)
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

1 개요

$base = array("orange", "banana", "apple", "raspberry");
$replacements = array(0 => "pineapple", 4 => "cherry");
$replacements2 = array(0 => "grape");

$basket = array_replace($base, $replacements, $replacements2);
print_r($basket);
# Array
# (
#     [0] => grape
#     [1] => banana
#     [2] => apple
#     [3] => raspberry
#     [4] => cherry
# )
$base = array("orange", "banana", "apple", "raspberry");
$replacements = array(0 => "pineapple", 5 => "cherry");
$basket = array_replace($base, $replacements);
print_r($basket);
# Array
# (
#     [0] => pineapple
#     [1] => banana
#     [2] => apple
#     [3] => raspberry
#     [5] => cherry
# )

2 같이 보기

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}