Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9145183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:27:03+00:00 2026-06-17T10:27:03+00:00

I want to create 5 different files that store data from my database. I

  • 0

I want to create 5 different files that store data from my database. I want to zip up the 5 files and have this function return the zip.

Can I create the 5 files without actually writing them to disk? The data I get from the db are only strings, so each file will be a long string.

I simply want to do this:

function getZippedFiles()
 // Create 1..5 files
 // Zip them up
 // Return zip
end

main()
// $zip_file = getZippedFiles();
end

Any information on how to do this is much appreciated, thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T10:27:05+00:00Added an answer on June 17, 2026 at 10:27 am

    Sure you can, it’s pretty simple with ZipArchive

    // What the array structure should look like [filename => file contents].
    $files = array('one.txt' => 'contents of one.txt', ...);
    
    // Instantiate a new zip archive.
    $zip_file = new ZipArchive;
    
    // Create a new zip. This method returns false if the creation fails.
    if(!$zip_file->open('directory/to/save.zip', ZipArchive::CREATE)) {
        die('Error creating zip!');
    }
    
    // Iterate through all of our files and add them to our zip stream.
    foreach($files as $file => $contents) {
        $zip_file->addFromString($file, $contents);
    }
    
    // Close our stream.
    $zip_file->close();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a helper method that could be called from different code-behind
I want to create a method sum that I can call on different types,
I want to create a website with various users. The users can have different
i want create a custom json data from the mssql 2008 results so that
I want to create a 2D array which can be used for two different
I want to create an overlay on top of Google Maps that displays different
I want to store the distance between different locations in a table. CREATE TABLE
I'm creating function which will read different XML files each time that will contain
I want to create an environment class that is accessible from all of my
Okay so I have a driver class called MonthlyReport that reads in data from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.