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...) Quote Link to comment 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 Quote Link to comment 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 Quote Link to comment 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? Quote Link to comment 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... Quote Link to comment 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 ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.