Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find then update value in tab delimited based on given arguments

Status
Not open for further replies.

iteach2

Technical User
Sep 16, 2001
120
US
Gurus,

My file looks like this.

SID Red Green
3142 1 1
1008 0 1
5241 1 0

I would like php to read this file tab delimited file then update column RED or Green based on the SID's that I supplied.

How is this done?

Do I add everything to an array first?

Thank you for your help
 
It will run one time; What I would do in plug all my SIDS into a value like:
3124
5142
1001
4004

Then I would input a value of 1 or 0 into the the field I want to be update on all the SIDS;

So when the script runs it would change the value of "RED" column to 1 or zero for all the SID's entered so if I entered SIDS

3124
5142 and then 0 value for "RED" value; after script runs RED is now 0 for those SIDs.
 
I don't understand what you're trying to do.

But if this script will not be run multiple times concurrently and if the file is not too big, you can read the entire thing into an array.



Want the best answers? Ask the best questions! TANSTAAFL!
 
Sorry for not being clear. Basically Id like to open a tab dilimited file into a php then have php locate SID 352 and 356, and 424. Once located goto the column called RED,which has a value of 0 or 1, for each of those SIDs, change the value of RED to the value of 0 or 1 that I have specified it to change to.

So perhaps after the code is run the tab delimited file will look like this.

SID RED

352 1
365 1
424 1

Before the update it would look like this.

SID RED

352 0
365 1
424 0
 
I would likely read the file into an array, then close the file. Then edit the values in the array. The write the array back to the file.





Want the best answers? Ask the best questions! TANSTAAFL!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top