Created
March 6, 2015 14:34
-
-
Save 4lb0/d61ea7006010afe685c9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$csv = array( | |
array('Jose', 'jose@tectonica.com', 'Buenos Aires, Argentina'), | |
array('Albo', 'albo@pragmore.com', 'New York, USA'), | |
); | |
$_POST['columns'] = array('firstname', 'email', 'location'); | |
$columns = $_POST['columns']; | |
$csvOrdered = array(); | |
foreach ($csv as $row) { | |
$rowOrdered = array(); | |
foreach ($columns as $position => $key) { | |
$rowOrdered[$key] = $row[$position]; | |
} | |
$csvOrdered[] = $rowOrdered; | |
} | |
var_dump($csvOrdered); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment