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
https://forums.phpfreaks.com/topic/208834-need-help-to-contruct-multi-level-array/
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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.