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 7533343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:42:05+00:00 2026-05-30T05:42:05+00:00

I want to store images in an array on every click before sending the

  • 0

I want to store images in an array on every click before sending the data for database injection.

Below is my dummy test, but I can’t get my head around to increase/ store the images array,

<?php
function add_image($image = array())
{
    # Loop and rename the table.
    foreach($image as $key => $item) 
    {
        $images[] = array(
            'image_id' => $image[$key]['image_id'],
            'image_title' => $image[$key]['image_title']
        );
    }

    return $images;
}

if($_REQUEST['add'] == '1')
{
    $image = array(
        array(
            'image_id' => 1,
            'image_title' => 'test 1'
        )
    );

    $images = add_image($image);

    var_dump($images);
}
if($_REQUEST['add'] == '2')
{
    $image = array(
        array(
            'image_id' => 2,
            'image_title' => 'test 2'
        )
    );

    $images = add_image($image);

    var_dump($images);
}           
?>
<a href="array_session.php?add=1">add 1</a>
<a href="array_session.php?add=2">add 2</a>

I will get a fresh image array on each click like this,

 array
      0 => 
        array
          'image_id' => int 1
          'image_title' => string 'test 1' (length=6)

or,

array
  0 => 
    array
      'image_id' => int 2
      'image_title' => string 'test 2' (length=6)

instead of

array
  0 => 
    array
      'image_id' => int 1
      'image_title' => string 'test 1' (length=6)
1 => 
    array
      'image_id' => int 2
      'image_title' => string 'test 2' (length=6)

Is it to do with session that I should be using?

  • 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-05-30T05:42:06+00:00Added an answer on May 30, 2026 at 5:42 am

    PHP session is really easy to use, you should start by reading documentation.

    Here is an example :

    // start session
    session_start();
    
    // init session var
    if (!isset($_SESSION['images'])) $_SESSION['images'] = array();
    

    After that, you just have to use $_SESSION[‘images’] to store your images data.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to store a large number of sound files in a database, but
I want to store a large result set from database in memory. Every record
I need to store images(I cropped them in a for loop,after every crop,I want
I understand the debate over whether to store images in the database but I'm
I have about 60 images I want to store in Core Data, 30 of
I want to store the images related to a each person's profile in the
I want to store the data returned by $_SERVER[REMOTE_ADDR] in PHP into a DB
I want to store a very large amount of vector data on a server
I've got a byte array for an image (stored in the database). I want
My problem is, I have multiple images and want to load like pre-loader, but

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.