Alternative to a multidimensional array??

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I've got an app I'm working on and a benefit to my users versus the
old application is dynamic forms. I didn't want to do it at first but
I figured it's something I'll have to do and the added benefit is
experience. Enough of the filler...

I'm generating the forms with javascript, based on information I know.
I use that information to tag the fields with that information. I
can't go into too much detail as I don't have the code with me right
now. Basically I'm tagging the fields like this:

date_<full date>_entry(n)_fieldname(n)

it's the easiest way I can think of. On the back side I'm building a
multi array like this(or similar):

$dates = array();

foreach ($_POST as $key => $value) {
   $key = strireplace("date_", "", $key);
   $keys = explode("_", $key);

   $date = $keys[0];
   $entry = $keys[1];
   $field = $keys[2];

    if (!in_array($date, $dates)
         $dates [] = $date;

   $date[$entry][$field] = $value;
   $keys = array();
   $date = "XX"; //clear them out...
   $entry = "XX";
   $field = "XX";


easy building? Extracting to put the information in the database, not
so much

foreach ($dates as $date) {
      foreach($$date as $entry ) {
           foreach($entry as $field => $value) {
                 $fieldNames[] = "'preappend" . $field "'";
                 $fieldValues[] = "'" . $value . "'";
          $insertFields = implode(",", $fieldNames);
          $insertFields .= ",preappendDate";
          $insertValues = implode(",", $fieldValues);
          $insertValues .= "," . $date;

          mysql_query("INSERT INTO table $insertFileds VALUES
($insertValues)", $connection) or die("ya mutha");

          $fieldNames = array(); //clean up <omitted the rest>

Is there a more efficient way of doing this? or did I put you asleep?
If it helps, this is basically an agenda builder.

Re: Alternative to a multidimensional array??

Wow, no takers?

Site Timeline