• 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

Input and output values for php into the browser?

woocommerce get_order_report_data to show order_item_id

Populate Dynamic Dropdowns List in Codeigniter

json_encode turns array into an object

Debugging Stripe Webhook Event

RuntimeException: Unable to create the cache directory (/var/www/sonata/app/cache/dev)

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given [duplicate]

Getting public posts of a random user from Facebook API

Limit WooCommerce products in cart only from one custom taxonomy

Why is this PHP array not the same?

Convert regular text to array using notepad++

Laravel 5.1 xmlHttpRequest AJAX POST TokenMismatchException

Getting error: CodeIgniterDatabaseBaseResult::getResult in CodeIgniter

Composer Curl error 60: SSL certificate problem: unable to get local issuer certificate

How to to send mail using gmail in Laravel?

About Contact Privacy policy Terms and conditions