Re: array question

From: Date: Mon, 24 Feb 2003 22:00:42 +0000
Subject: Re: array question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-137000@lists.php.net to get a copy of this message
try something like this: $groups= file("group"); $number_in_group = count($groups); for( $i = 0; $i < $number_in_group; $i++) { $temp = explode(":",$groups[$i]); $group[$i]['pass'] = $temp[1]; $group[$i]['id'] = $temp[2]; $group[$i]['list'] = $temp[3]; } for( $i = 0; $i < count( $group ); $i++) { echo "site" . $i . ":" . $group[$i]['pass'] . ":" . $group[$i]['id'] . ":"; $temp = explode( ",", $group[$i]['list'] ) foreach ($temp as $k => $v) echo $v; } -- Chris Edwards Web Application Developer Outer Banks Internet, Inc. 252-441-6698 chris.edwards@obinet.com http://www.OuterBanksInternet.com ----- Original Message ----- From: "Richard Kurth" <rdkurth@starband.net> To: "php-general" <php-general@lists.php.net> Sent: Monday, February 24, 2003 3:23 PM Subject: [PHP] array question > This is the code I am using to get the data out of the text file > below. Now I need to turn the $group[3] into an array of its own so > that I can make changes to it. How do I turn this into an array that > I can reference with $group[0]. What I need to be able to do is > search for the label in $group[0] and then make changes to the stuff > in $group[3] like delete add or change. > > <? > $groups= file("group"); > $number_in_group = count($groups); > ?> > <table border="1"> > <? > for ($i=0; $i<$number_in_group; $i++){ > $group=explode(":",$groups[$i]); > ?> > <tr> > <td><? echo$group[0]?></td> > <td><? echo$group[3]?></td> > </tr> > <?}?> > </table> > > > The DATA > > site1:x:503:tester1 > site2:x:504:tester2,tester2a > site3:x:505:tester3,tester3a,tester3b > site4:x:506:tester4 > site5:x:507:tester5,tester5a,tester5b > site6:x:508:tester6 > site7:x:509:tester7,tester7a,tester7b > > > > -- > Best regards, > Richard mailto:rdkurth@starband.net > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.general (#137000) next »