title: Search CSV file and then Return specific rows from CSV file using PHP?
body: <p>I know this question has been asked before but my problem is different because I need to return the specific rows after a search.</p>
  
  <p>Basically, this is the scenario:</p>
  
  <p>I need to search a CSV file for a specific word/string in the <code>name</code> column and then IF the word/string is found I need to get the <code>row[4]</code> and <code>row[5]</code> and print them in the PHP.</p>
  
  <p>The CSV looks like this:</p>
  
  <pre><code>"id","ident","type","name","latitude_deg","longitude_deg","elevation_ft"
  6523,"00A","heliport","Heliport",40.07080078125,-74.93360137939453,11,
  </code></pre>
  
  <p>So basically, I need to search by <code>name</code> and if found, return the <code>latitude_deg</code>,<code>longitude_deg</code>.</p>
  
  <p>This is what I have so far... However, this searches the ENTIRE CSV file which makes it slightly slower and it only returns whether the CSV file contains the string/word or not...</p>
  
  <pre><code>$search      = "Heliport";
  $lines       = file('myCsv.csv');
  $line_number = false;
  
  while (list($key, $line) = each($lines) and !$line_number) {
     $line_number = (strpos($line, $search) !== FALSE);
  }
  
  if($line_number){
      echo "Results found for " .$search
  } else {
      echo "No results found for $search";
  }
  </code></pre>
  
  <p>Could someone please advice on this issue? Thanks in advance. </p>