xwishmasterx Posted June 19, 2012 Share Posted June 19, 2012 hello I have a ".dat" file that contains looks like this: 500,1000,1000,,2000, 400,800,800,,1000, 300,600,600,,750, 200,400,400,,500, 100,200,200,,300, ,,,,, How can I retrive these values and work with them? (eg: UPDATE * SET points= 500 from the top row, other_points=300 from the last row...) Link to comment https://forums.phpfreaks.com/topic/264458-how-do-i-get-text-text-data-from-a-dat-file-and-work-with-it/ Share on other sites More sharing options...
Jessica Posted June 19, 2012 Share Posted June 19, 2012 http://us.php.net/manual/en/function.fgetcsv.php Link to comment https://forums.phpfreaks.com/topic/264458-how-do-i-get-text-text-data-from-a-dat-file-and-work-with-it/#findComment-1355261 Share on other sites More sharing options...
xwishmasterx Posted June 19, 2012 Author Share Posted June 19, 2012 manual is written in Greek..I never get any help from it, why I ask in this forum Link to comment https://forums.phpfreaks.com/topic/264458-how-do-i-get-text-text-data-from-a-dat-file-and-work-with-it/#findComment-1355265 Share on other sites More sharing options...
Barand Posted June 19, 2012 Share Posted June 19, 2012 So someone can write the code for you? Link to comment https://forums.phpfreaks.com/topic/264458-how-do-i-get-text-text-data-from-a-dat-file-and-work-with-it/#findComment-1355277 Share on other sites More sharing options...
xwishmasterx Posted June 19, 2012 Author Share Posted June 19, 2012 nevermind, I'll get help somewhere else... Link to comment https://forums.phpfreaks.com/topic/264458-how-do-i-get-text-text-data-from-a-dat-file-and-work-with-it/#findComment-1355283 Share on other sites More sharing options...
Barand Posted June 20, 2012 Share Posted June 20, 2012 TEST.DAT 500,1000,1000,,2000 400,800,800,,1000 300,600,600,,750 200,400,400,,500 100,200,200,,300 Example code: <?php $fh = fopen('test.dat', 'r'); $data = array(); while ($line = fgetcsv($fh, 1024)) { $data[] = $line; } fclose($fh); $lastline = count($data) - 1; $lastitem = count($data[$lastline]) - 1; echo "First data item : {$data[0][0]}<br />"; // 500 echo "Last data item : {$data[$lastline][$lastitem]}<br />"; // 300 ?> Link to comment https://forums.phpfreaks.com/topic/264458-how-do-i-get-text-text-data-from-a-dat-file-and-work-with-it/#findComment-1355405 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.