php - multi dimensional array formated echo by index -


array (     [1] => array         (             [0] => 1             [1] => none             [2] => none         )      [2] => array         (             [0] => none             [1] => 2             [2] => none         )      [3] => array         (             [0] => none             [1] => 2             [2] => 3         )  ) 

hello experts have array check boxes , want echo index values i.e. in order of keys 0 index values in 1 pocket , 1 index values in 1 pocket example [[0, 0, 0], [1, 1, 1], [2, 2, 2]] values [[1, none, none], [none, 2, 2], [none, none, 3]] please can me ?

$myarray = array(   1 => array( 0 => 1, 1 => "none", 2 => "none"),                                        2 => array( 0 => "none", 1 => 2, 2 => "none"),                                        5 => array( 0 => "none", 1 => 2, 2 => 3) );    $newarray = array(); foreach( $myarray $masterindex => $childarray ) {     foreach( $childarray $index => $value )          {         if( !isset($newarray[$index]) )         {             $newarray[$index] = array();         }         $newarray[$index][] = $value;     } }  $outputvalues = "[";   foreach( $newarray $childarray )  {          $outputvalues .= "[" . implode(",", $childarray) . "],"; }  $outputvalues = substr($outputvalues, 0, strlen($outputvalues) -1) . "]"; echo $outputvalues; 

that refined version, 'implode' instead of loop...


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -