Jump to content

need help to contruct multi-level array


jasonc

Recommended Posts

I have many forms each with many fields.

 

I wish to simplify the alteration of these as the process is long winded (edit form, update each line, edit return page file and so on.

 

I have a function that will create the forms and one to read the info sent.

 

What I am having problems with is creating the array with all the form data fields and id's and names.

 

I am wishing to use a simple method say...

 

$array[contactusform][name][fieldid]  (which would return say 'name'  which would be the fieldid)

$array[contactusform][name][fieldtext]  (which would return say 'Please enter you name*'  which would be the text shown beside the text field)

and so on..

 

can anyone suggest a way to do this in a single array, as i am currently having each form in a seperate array which is now not going to work with new features i wish to introduce the to site.

Link to comment
Share on other sites

How about something like this?

 

$arr = array ( 'contactusform' => array ( 
          'field1' => array ( 
                     'fieldid' => 'nameField', 
                     'fieldtext' => 'Name'
           ), 
           'field2' => array ( 
                      'fieldid' => 'nextField', 
                       'fieldtext' => 'stuff here' 
             )
);

 

~juddster

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.