Jump to content

two dimension hidden field


haku87

Recommended Posts

well since the link was down for you i have copied the code here...

 

FROM THE SITE

 

 

takes a multidimensional array and puts all the elements into HTML hidden input types so data can be carried through to another page


<?php
function array_to_hidden($array, $carry = "data") {

    /* feed it a multidimensional array and it goes right down putting every
     * non-blank element of every sub-array into a HIDDEN field of an HTML
     * FORM. The second argument should be the name of the variable
     *  you've passed */

    while(list($name, $value) = each($array)) {

        if (is_array($value)):
            array_to_hidden($value, "${carry}[$name]");

        /* uncomment the "elseif" if you don't want fields with blank values to be
         * passed along. (don't forget to comment out the else of course!) */

        //elseif (!ereg("^[ nt]*$", $value)):
        else:
            echo "n<INPUT TYPE="hidden" NAME="${carry}[$name]" ",
            "VALUE="$value">";
        endif;

    }

} 

?> 

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.