title: How do I get a column in CSV in reverse order into php?
body: <p>I would like to know how can I get a specific column (in my case the second column) from CSV in reverse order into PHP? For example if my file is</p>
  
  <pre><code>my, name, is, marwan
  here, goes, thing, some
  1, 2, 3, 4
  </code></pre>
  
  <p>Now the output the I want in php would be</p>
  
  <pre><code>my -      some -    1
  name -    thing -   2
  is -      goes -    3
  marwan -  here -    4
  </code></pre>
  
  <p>My existing PHP code for printing everything in normal order is</p>
  
  <pre><code>for($num = 1; $num &lt;= 1; $num++) {
  
          if(file_exists('1.csv')) {
  
            $csvData = file_get_contents('1.csv');
            $lines = explode(PHP_EOL, $csvData);
            $array = array();
            foreach ($lines as $line) { $array[] = str_getcsv($line); }
  
            // count number of columns and minus 1 from it
            $count =  count($array[0]) - 1;
  
            for ($x = 0; $x &lt;= $count; $x++) {
  
              $first_column = $array[0][$x];
              $second_column = $array[1][$x];
              $third_column = $array[2][$x];
  
             // Now just outputting the values...
  
            ";
            }
  
          }
        }
  </code></pre>
  
  <p>Thank you.</p>