• 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

php file upload scanning using clamav, permissions on /tmp/

Insert And Retrieve Data in MySQL with $.post Noob Question

Mobile browsers are adding .html to filename on download

Remove categories with all childs derived from parent category

How to implement placeholder in a php file for moodle plugin?

Chunk and transpose a flat array into rows with a specific number of columns

Laravel 5 session not persisting after user is logged in

How to load Codeigniter 4 lang file into an array variable

Currently Using CodeIgniter Framework i have an Error

Declaration of OMDb::query(string $statement) must be compatible with PDO::query

How to install php yaml on CentOs?

Make Calculator - When Button clicked the No shows in Textbox.

Check if string contains a value in array [duplicate]

Laravel PackageManifest.php: Undefined index: name

CodeIgniter force_download is not working

About Contact Privacy policy Terms and conditions