Jump to content

Sonva

New Members
  • Posts

    2
  • Joined

  • Last visited

Everything posted by Sonva

  1. That's perfect, thanks so much both! Much simpler than I'd thought in the end! 😄
  2. I'm currently writing a script to display the fields from a large CSV and display them in arrays. Currently I have a working script as below: <?php function csvToArray($csvFile){ $file_to_read = fopen($csvFile, 'r'); while (!feof($file_to_read) ) { $lines[] = fgetcsv($file_to_read, 1000, ','); } fclose($file_to_read); return $lines; } $csvFile = 'example.csv'; $csv = csvToArray($csvFile); echo '<pre>'; print_r($csv); echo '</pre>'; ?> This returns every line of the CSV into arrays. However, what I want to do next is have only specific fields be returned in these arrays, and have said fields be named. So, for example, right now the output looks something like: (0) => (1) => £100 (2)=> Cancelled (3) => (4) => But what I want to output would be something like: (Subscription Cost) => £100 (Subscription Status) => Cancelled Can someone give me a hand with how to achieve this? I've never used any CSV functions with PHP before so I'm starting from scratch currently with my knowledge.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.