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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

array question

Status
Not open for further replies.

cleansedbb

Technical User
Feb 11, 2002
95
US
I have a text file that includes the following info that is generated by my cgi scripts.

name, ip, session id
name, ip, session id

I want to read that into an array and later disply
online users by name, ip, session id.

not sure how to start on this.

 
possibly u can use smthng like the folllowing:

$array = array('name', 'ip', 'session-id');

then use $array in any way u like ;-)
 
try this:

$fp = fopen("filename.txt",r) ;

while(!feof($fp)) {// read file line by line
$line = fread($fp,1000) ;
list($name,$ip,$session_id) = spilt(",",$line) ;

//display the record

echo "name: ".$name ;
echo "ip: ".$ip ;
echo "session id: ".$session_id ;

}







--------------------------------------------------------------------------
I never set a goal because u never know whats going to happen tommorow.
 
can you do tab delimited as well?

both worked well thanks
 
yes u can!!
spilt the string with "\t" to get the record
list($name,$ip,$session_id) = spilt("\t",$line) ;



--------------------------------------------------------------------------
I never set a goal because u never know whats going to happen tommorow.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top