• 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

Prevent blank space in pdf pages (DomPdf)

Facebook SDK error: Cross-site request forgery validation failed. Required param "state" missing from persistent data

Symfony autowiring issues since docker update

Why the name of trucks are same in 2nd and 3rd record of company data retrieval?

Clients authentication and user authentication with laravel

PHP Include for HTML?

HTTP Range requests with php for Video Embedding for solving going to specific time in video (seek bar not work)

Zig-zag scan an N x N array

Creating command to backup MySql database in Laravel

get folder directory from input type file - PHP

file_get_contents() without "Http" to access external URL [closed]

Send same name multiple checkbox values via ajax

How can I make Laravel return a custom error for a JSON REST API

PHP and WebView - Cookie doesn't are the same

yii2 and mssql insert varbinary into model

About Contact Privacy policy Terms and conditions