note 3313 deleted from list by ronabop

From: Date: Thu, 31 Aug 2000 05:35:02 +0000
Subject: note 3313 deleted from list by ronabop
Groups: php.notes 
Request: Send a blank email to php-notes+get-3732@lists.php.net to get a copy of this message
I am trying to edit a certain portion of a file, which has lines individually containing something like this: <PRE>user;name;email;score</PRE> I need to change the "score" part of one of those lines when I come to a specific "user". I tried to use a while loop with list($key, $val) and change the $val variable to one incremented when it came to $key == 4, but it seems like it did not change the value of it. I use implode() to put the variables back together... here is my code: <PRE>$fp = file("Agents/list.dat"); while(list($key,$val)=each($fp)) { $array = explode(";",$val); while(list($key2,$val2)=each($array)) if ($key2 == 3) { $val2 = 1; $array2[$x+=1] = implode(";", $array); } } $newfp = implode("<br>n", $array2); print("$newfp");</PRE>

« previous php.notes (#3732) next »