PHP CSV, how to get previous and next 3 rows from current row
- by Kalpesh Mehta
I am currently using fgetcsv in php to get rows in CSV file. For each row, I need it's 3 previous rows and 3 next rows for some requirement.
while(($data = fgetcsv($handle, 5000, ",")) !== FALSE) {
//$data is current row data
//I need previous rows and next rows data
}
I don't know how to try this, as each while iterate will be having the current row's information.
Is there anything we can achieve this within the fgetcsv loop? I am also open for other alternatives for this problem.