I have file that is delimetered by a comma like below
Big2,red,0,Y
Big2,blue,0,N
Big2,green,1,N
Big6,red,0,Y
Big6,blue,0,N
Big6,green,1,N
Big6,yellow,0,Y
Big6,black,0,Y
Following is the code I used to read the file
$file_content = explode("\n",(file_get_contents("inven.csv")));
foreach ($file_content as $key => $value) {
$value = str_replace(array('\'', '"'), '', $value);
$line_records = explode(',', $value);
$reference = trim($line_records[0]);
$option = trim($line_records[1]);
$quantity = trim($line_records[2]);
$discontinued = trim($line_records[3]);
}
I want to check for the following condition and perform some action
- If the 1st, 2nd and 4th field are the same for all lines
- If all "Big2" rows have the 3rd field = 0 and the 4th field = Y