Q:

How to filter on a word in a specific column of a csv file with PHP

I'm trying to display only the rows that contain a specific word in a specific column. Basically I would like to show only the rows that have "yes" in the Display column.
First_Name, Last_Name, Display
Kevin,      Smith,     yes
Jack,       White,     yes
Joe,        Schmo,     no

I've been trying various things with fgetcsv & str_getcsv from other answers and from php.net but nothing is working so far.
It doesn't do anything but this is my current code:
$csv  = fopen('file.csv', 'r');

$array = fgetcsv($csv);

foreach ($array as $result) {
    if ($array[2] == "yes") {
        print ($result);
     }
}

A:

Let's have a look at the documentation for fgetcsv():

Gets line from file pointer and parse for CSV fields

fgetcsv reads a single line, not the whole file. You can keep reading lines until you reach the end of the file by putting it in a while loop, e.g.
<?php

$csv  = fopen('file.csv', 'r');

// Keep looping as long as we get a new $row
while ($row = fgetcsv($csv)) {
    if ($row[2] == "yes") {

        // We can't just echo $row because it's an array
        //
        // Instead, let's join the fields with a comma
        echo implode(',', $row);
        echo "\n";
    }
}

// Don't forget to close the file!
fclose($csv);

