Transpose csv file data [duplicate]



PHP Snippet 1:

$newArray = array(
    't' => array_column($array, 3),
    'o' => array_column($array, 4),
    'h' => array_column($array, 5),
    ...
);

PHP Snippet 2:

$keys = array('t','o','h','l','c','v');    
$newArray = array();

foreach ($array as $j) {
    $r = array_slice($j, 3);
    foreach ($r as $i => $v) $newArray[$keys[$i]][] = $v*1; 
}

PHP Snippet 3:

"t":[1437144900,1437144900,1437145020],
"o":[1.5607,1.5607,1.56084],
"h":[1.5607,1.5607,1.56096],
"l":[1.56064,1.56064,1.56084],
"c":[1.56064,1.56064,1.56094],
"v":[2,2,5]

PHP Snippet 4:

0.020426