• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

Transpose csv file data [duplicate]

phparraystranspose


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

Related Snippets

HTML + PHP + PHPMAILER

How to set time with DateTime modify?

PHP date() with timezone?

find in set in laravel ? example

IlluminateDatabaseQueryException: SQLSTATE[HY000]: General error: 1 no such table - In clone project

Sort a multidimensional array by integer inside of a string value which is two levels down

api response laravel doesn't show

Insert multidimensional array to codeigniter cart

How to programmatically find public properties of a class from inside one of it's methods

Laravel Nova Dependency Container what are the allowed resource properties other than id in dependsOn

Laravel Multi-language routes without prefix

How do I truncate a decimal in PHP?

Sum column values from multiple arrays

Convert every two values of an associative array into key-value pairs

PHPUnit 7: Failed asserting that exception of type InvalidArgumentException is thrown

About Contact Privacy policy Terms and conditions