Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Set your CSV feed
- $feed = 'https://docs.google.com/spreadsheets/d/1Y6TNGpUkoCQzLtATw4LeIUFGTsZbXBx0mQAT_csKtyY/export?format=csv';
- // Arrays we'll use later
- $keys = array();
- $newArray = array();
- // Do it
- $data = csvToArray($feed, ',');
- // Set number of elements (minus 1 because we shift off the first row)
- $count = count($data) - 1;
- //Use first row for names
- $labels = array_shift($data);
- foreach ($labels as $label) {
- $keys[] = $label;
- }
- // Add Ids, just in case we want them later
- $keys[] = 'id';
- for ($i = 0; $i < $count; $i++) {
- $data[$i][] = $i;
- }
- // Bring it all together
- for ($j = 0; $j < $count; $j++) {
- $d = array_combine($keys, $data[$j]);
- $newArray[$j] = $d;
- }
Advertisement
Add Comment
Please, Sign In to add comment