Manipulating a text file
| From: | Richard Kurth | Date: | Wed, 26 Feb 2003 22:14:22 +0000 |
| Subject: | Manipulating a text file | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-137313@lists.php.net to get a copy of this message | ||
Hello php-general,
I need to be able to add and delete to a text file that look like
this. I only need to manipulate the part after site:x:503:
site1:x:503:tester1,tester6
site2:x:504:
site3:x:505:
site4:x:506:
site5:x:507:
site6:x:508:
site7:x:509:tester2,tester3,tester4
site8:x:510:
site9:x:511:
I can get to this value by using this code below. But I have know Idea
on how to go about this. I want to be able to add to this list and
delete from the list. Example I would like to remove tester3 from
site7 and then I would like to add tester10 to site4. This should give
you an idea of what I am trying to do. I have asked this question
before but have never received an answer that I could understand.
$groups= file("group");
$number_in_group = count($groups);
for( $i = 0; $i < $number_in_group; $i++){
$group = explode(":",$groups[$i]);
$group[0];
$group[3]; //this is the group I what to be able to change but referenced by group[0]
I need to be able to add to and delete from this group and then save it to a file
}
--
Best regards,
Richard mailto:rdkurth@starband.net