talor123 Posted June 2, 2008 Share Posted June 2, 2008 hey, im not realy to good at php, does anyone happen to no a code that does the following: 1)gets a files contents(i no how to use 'file_get_contents') this is the bit i do not no how to do: 2) the script will read the file and set each line to a numbered variable.. eg: the variable 1 would be set to the first line of text the variable 2 would be set to the second line of text and so on... thanx in advanced Link to comment https://forums.phpfreaks.com/topic/108340-php-variables/ Share on other sites More sharing options...
DarkerAngel Posted June 2, 2008 Share Posted June 2, 2008 I'm not going to make a script for you but read into this: http://us3.php.net/manual/en/function.fgets.php Link to comment https://forums.phpfreaks.com/topic/108340-php-variables/#findComment-555431 Share on other sites More sharing options...
haku Posted June 2, 2008 Share Posted June 2, 2008 no != know. Link to comment https://forums.phpfreaks.com/topic/108340-php-variables/#findComment-555434 Share on other sites More sharing options...
mushroom Posted June 2, 2008 Share Posted June 2, 2008 2) the script will read the file and set each line to a numbered variable.. eg: the variable 1 would be set to the first line of text the variable 2 would be set to the second line of text and so on... thanx in advanced Note: variables can not start with a number. but it can be done with code some thing like this $i=0; # open file # loop through file. {$var="varname".$i; $$var=$line; # read each line $i++; } I have use this in the past, but now prefer to use arrays they are much easier to work with later. # open file # loop through file. { $array_name[]=$line; # read each line } Link to comment https://forums.phpfreaks.com/topic/108340-php-variables/#findComment-555708 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.