how to pass array through hidden field

后端 未结 7 2015
醉梦人生
醉梦人生 2020-12-05 00:59

here my code

$order[$j][0]=\"Euclidean Geomethiyil Kodpagugal\";
$order[$j][1]=$q16;
$j++;

hidden field-



        
7条回答
  •  南方客
    南方客 (楼主)
    2020-12-05 01:41

    An alternative solution to serializing to a single field is to serialize to multiple hidden fields. I wrote a generic function to do this. This function and the examples are being managed at GistHub's Gist service. Check there for the latest version but copied here for convenience.

     $value) {
          if( empty($prefix) ) {
            $name = $key;
          } else {
            $name = $prefix.'['.$key.']';
          }
          if( is_array($value) ) {
            array_to_input($value, $name);
          } else { ?>
            
          
            
          

    Here is some example usage:

    Basic Associative Array

    echo array_to_input(array('foo' => 'bar', 'cat' => 'dog'));
    

    Will output:

    
    
    

    Associative Array with Nested Indexed Array

    echo array_to_input(array('foo' => 'bar', 'cat' => 'dog', 'list' => array('a', 'b', 'c')));
    

    Will output:

    
    
    
    
    
    

    Associative Array with Nested Associative Array

    echo array_to_input(array('foo' => array('bar' => 'baz', 'a' => 'b'), 'cat' => 'dog'));
    

    Will output:

    
    
    
    

    Go Crazy

    echo array_to_input(array('a' => array('b' => array('c' => array('d' => 'e')))));
    

    Will output:

    
    

提交回复
热议问题