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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:00:00+00:00 2026-05-14T03:00:00+00:00

I have a PHP page that queries a DB to populate a form for

  • 0

I have a PHP page that queries a DB to populate a form for the user to modify the data and submit.
The query returns a number of rows which contain 3 items:

  1. ImageID
  2. ImageName
  3. ImageDescription

The PHP page titles each box in the form with a generic name and appends the ImageID to it. Ie:

  • ImageID_03
  • ImageName_34
  • ImageDescription_22

As it’s unknown which images are going to have been retrieved from the DB then I can’t know in advance what the name of the form entries will be.
The form deals with a large number of entries at the same time.

My backend PHP form processor that gets the data just sees it as one big array:

[imageid_2] => 2
[imagename_2] => _MG_0214
[imageid_10] => 10
[imagename_10] => _MG_0419
[imageid_39] => 39
[imagename_39] => _MG_0420
[imageid_22] => 22
[imagename_22] => Curly Fern
[imagedescription_2] => Wibble
[imagedescription_10] => Wobble
[imagedescription_39] => Fred
[imagedescription_22] => Sally

I’ve tried to do an array walk on it to split it into 3 arrays which set places but am stuck:

// define empty arrays
$imageidarray = array();
$imagenamearray = array();
$imagedescriptionarray = array();

// our function to call when we walk through the posted items array
function assignvars($entry, $key)
{
 if (preg_match("/imageid/i", $key)) { 
  array_push($imageidarray, $entry);
 } elseif (preg_match("/imagename/i", $key)) {
//     echo " ImageName: $entry";
 } elseif (preg_match("/imagedescription/i", $key)) {
//     echo " ImageDescription: $entry";
 }
}

array_walk($_POST, 'assignvars');

This fails with the error:
array_push(): First argument should be an array in…

Am I approaching this wrong?

  • 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-14T03:00:00+00:00Added an answer on May 14, 2026 at 3:00 am

    Would it be possible to change the way the items are named on the form?

    Current:

    • ImageID_03
    • ImageName_34
    • ImageDescription_22

    Changed To:

    • ImageID[03]
    • ImageName[34]
    • ImageDescription[22]

    This way it should come through the $_POST as three separate arrays meaning you can skip all that extra processing.

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

Sidebar

Related Questions

I have a php page that displays rows from a mysql db as a
I have a php function that dynamically queries a database, and returns 6 tables.
I have a particular PHP page that, for various reasons, needs to save ~200
I have a page that is accessed via a URL like this: http://power-coder.net/Test/something.php?id=3#Page1 I
I'd like to have a page in php that normally displays information based on
I have a PHP-generated page which is displaying some data about a set of
Let's say I have a page called display.php and the user is viewing display.php?page=3
I have a Flash movie that is embeded in a PHP page. The PHP
I have a site with URLs like this: http://domain.co.uk/subdir/page.php I have redesigned the site
How do I pass have a Javascript script request a PHP page and pass

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.