Display specific data from CSV using PHP -



Display specific data from CSV using PHP -

the code have below working narrow downwards results. @ moment shows info column 1 (date), 2 (name), , 3 (result).

now, search csv word 'won' in column 3 , limit search 3 results. example, show latest 3 games have got word 'won' in column 3.

$file_handle = fopen("future.csv", "r"); while (!feof($file_handle) ) { $line_of_text = fgetcsv($file_handle, 1024); print $line_of_text[1] . $line_of_text[2]. $line_of_text[3] . "<br />"; } fclose($file_handle);

any help much appreciated. cheers.

keep counter of how many times "won" shows up, , when it's 3/more stop looping.

$file_handle = fopen("future.csv", "r"); $counter = 1; while (!feof($file_handle) ) { $line_of_text = fgetcsv($file_handle, 1024); if (strpos($line_of_text[3], 'won') !== false) { print $line_of_text[1] . $line_of_text[2]. $line_of_text[3] . "<br />"; if ($counter++ >= 3) break; } } fclose($file_handle);

php csv

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -