Jump to content

timr

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Everything posted by timr

  1. Thank you very much for your reply! I was in the mindset that there must be a specific function just for csv. However, your way makes WAY more sense and works perfectly for what I am trying to achieve! SOLVED! Thanks again.
  2. Hello and thanks for the reply. My code: if($parts[$c]=='Norway') { $parts[$c]='It works'; //code to modify the csv value in the file } Only modifies the variable. I am actually looking to modify the csv file itself. My real csv file is extremely large so here is an example of how it is setup: "Bruno","Gammit","Wind" "John","Stewy","Norway" Any idea on how I could modify the csv file itself to replace the searched value (in my example "Norway") with the new value (in my example "it works")? All help is greatly appreciated!
  3. The first thing that comes to mind is to put a timestamp in the row, and evaluate the timestamp on the login page or a header/include file. This way if a user "times out" or just closes the window without logging out, the next person who logs in will execute a script to check the users table for out dated timestamps. If the timestamp is older than x amount of time, then delete the row or mark it offline. Hope this helps.
  4. Hello All, I am trying to modify a value found in a csv file and I can't seem to figure this out. I already looked into fputcsv and cannot seem to make it work to just modify a value. I have a script now that outputs the csv into a table and displays a count for how many rows there are. I am parsing through a very large file and (for example) I want to replace all instances of the word "Norway" with "it works". Here's what I have so far: <?php $filename='Test.txt'; $count=0; $c=0; echo '<table border=1>'; $file_handle = fopen($filename, "r+"); while (!feof($file_handle) ) { $parts = fgetcsv($file_handle); echo '<tr><td>'.$count.'</td>'; while($c<=3) { if($parts[$c]=='Norway') { $parts[$c]='It works'; //code to modify the csv value in the file } echo '<td>'. $parts[$c] .'</td>'; $c++; } $c=0; "</tr>"; $count++; } fclose($file_handle); echo '</table>'; ?> I have looked all over and can't find any examples of how to do this. Any help would be greatly apprecieated!!!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.