함수 array replace()

array_replace()

1 PHP[ | ]

PHP
CPU
0.0s
MEM
22M
0.0s
Copy
$base = ["orange", "banana", "apple", "raspberry"];
$replacements = [0 => "pineapple", 4 => "cherry"];
$replacements2 = [0 => "grape"];

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

2 Ruby[ | ]

Ruby
Copy
def array_replace(base, replacements)
	return replacements + base.drop(replacements.size)
end

a = ["orange", "banana", "apple", "raspberry"]
b = ["pineapple", "cherry"]

puts array_replace(a, b)
# pineapple
# cherry
# apple
# raspberry

puts array_replace(b, a)
# orange
# banana
# apple
# raspberry

3 같이 보기[ | ]

  • PHP 파일 다운로드 구현 2 (한글 파일명 지원)
    제가 파일다운로드 관련된 것이 서툴러서 파일 다운로드 부분을 인용하였습니다. 죄송합니다.
  • PHP에서 오라클 DB 사용
    감사합니당. YoWu
  • PHP 파일 업로드 구현
    파일정보 출력에서 $name $ext 가 정상적으로 출력되나요? 전부 echo의 쌍따옴표안에 있는데? 일리단사오육칠
  • PHP 파일 업로드 구현
    PHP echo에서 쌍따옴표 안의 변수는 해석되어 출력됩니다. 위 소스에서도 $name와 $ext가 두껍게 나와있죠? 일반 문자열과는 다르다는 표시죠.J Jmnote
  • PHP 파일 다운로드 구현 2 (한글 파일명 지원)
    'Windows NT 6.1' << 이부분은 접속한 윈도우의 플랫폼을 뜻하는걸로 압니다. ie11 접속하면 다음과 같이 바뀌었고 Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko rv:11.0 << 이부분이 Anmkst
  • Lib my.php
    Fatal error: Uncaught Error: Call to undefined function insert_rows() in D:\xampp\htdocs\naru\import_excel.php:38 Stack trace: #0 {main} thrown in D:\xampp\htdo 신정섭
  • Lib my.php
    함수 query()를 사용하면 됩니다. 예시 추가했으니 참고바랍니다.J Jmnote
  • 로또번호 생성
    초보를 위한 개발 실습 과제로군요 ㅎㅎ Pinkcrimson