php
![[PHP] 다차원 배열 1차원 배열로 바꾸기](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdna%2Fme7v3%2FbtrxUP7J8JX%2FAAAAAAAAAAAAAAAAAAAAANcRvf8ku2wXAxGbAW351pZVK8K_7AiywG-BX1t4nuuP%2Fimg.png%3Fcredential%3DyqXZFxpELC7KVnFOS48ylbz2pIh7yKj8%26expires%3D1756652399%26allow_ip%3D%26allow_referer%3D%26signature%3Dsip%252Bu6v%252BmAypVxcPA%252Bnq38hU37o%253D)
[PHP] 다차원 배열 1차원 배열로 바꾸기
코드 $multiArr = [['a', 'b', 'c'], [1, 2, 3]]; $arr = array_merge(...$multiArr); // ['a', 'b', 'c', 1, 2, 3]; 하위 배열 요소를 묶어 새로운 배열을 만드는 방법입니다. PHP 5.6 이상에서 array_merge 함수로 간단하게 2차원 배열을 병합할 수 있습니다. 해당 코드는 키가 적용된 배열에서도 정상 작동되며 안될 시 아래 코드를 사용해보세요. $arr = array_merge(...array_values($multiArr));
![[PHP] 파일 다운로드](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdna%2Fctwkso%2FbtrxYbh5MAw%2FAAAAAAAAAAAAAAAAAAAAAHp_u2RhTmf8ecyGiRAgDZpY1kSdTV1K8lwt9WraoXBe%2Fimg.png%3Fcredential%3DyqXZFxpELC7KVnFOS48ylbz2pIh7yKj8%26expires%3D1756652399%26allow_ip%3D%26allow_referer%3D%26signature%3DNGYqV17B0DiVG8GkJ8ocIgCQFhI%253D)
[PHP] 파일 다운로드
코드 $fe = fopen("파일경로", "r"); header("Content-Disposition:attachment; filename=다운로드 되는 파일 이름"); header("Content-Type:file/unknown;"); fpassthru($fe); php 파일 다운로드는 http 요청을 변경하여 구현할 수 있습니다.
![[PHP] 다중 파일을 ZIP 압축 파일로 다운로드하기](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdna%2FMY0Fi%2Fbtrx1Ilana6%2FAAAAAAAAAAAAAAAAAAAAAFUaj7YlQDp6JfeXoM2RRtc-XydeIicFD9DoZmipfzM2%2Fimg.png%3Fcredential%3DyqXZFxpELC7KVnFOS48ylbz2pIh7yKj8%26expires%3D1756652399%26allow_ip%3D%26allow_referer%3D%26signature%3DPublvlJx098lWiIYmf1zMoy62NY%253D)
[PHP] 다중 파일을 ZIP 압축 파일로 다운로드하기
코드 // 가상의 경로를 가진 배열 생성 $files = ['upload/zipFile_1.txt', 'upload/zipFile_2.txt']; $filePath = $_SERVER['DOCUMENT_ROOT']."/"; $zip = new ZipArchive(); // zip 아카이브 생성하기 위한 고유값 $zipName = time()."zip"; // zip 아카이브 생성 여부 확인 if (!$zip->open($zipName, ZipArchive::CREATE)) { exit("error"); } // addFile ( 파일이 존재하는 경로, 저장될 이름 ) foreach ($files as $fileName) { $zip->addFile($filePath.$fileName, $fileName)..