Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Reading from txt file
November 29, 2005, 4:37 pm
rate this thread
$username = $_POST['username'];
$myFile = "clientlist.txt";
$fp = fopen($myFile, 'r');
$content = fread( $fp, filesize( $myFile ) );
$inputString = $username;
$arrFp = file( $myFile ); // Open the data file as an array
$numLines = count( $arrFp ); // Count the elements in the array
$arrWords = explode( ' ', $inputString ); // Split the input string
into words as an array
$numWords = count( $arrWords ); // Count the words in the string
for($i=0; $i<$numWords; $i++) // Loop through the words in the string
for($j=0; $j<$numLines; $j++) // Loop through the lines of the
$outputString .= $arrWords[$i].' ';
And I need it to read a txt file that has something like:
I need the outputString to be what is between the "" and not the
Right now it is outputting the same as the $username.
How do I change the code to select what is between the "" in the text
Thank you for any help,
Re: Reading from txt file
user1, user2, user3, etc....
Those are just hypotetical and being used for testing purposes.
The login is a simple login using POST and the page receiving the POST
data is a page where images are displayed.
I was abble to just get the variable sent by the form and use that to
display the images since the images are named user1_1.jpg,
But now I have to find a way to add a line like:
"Welcome to baby "familyname"'s page!"
The "familyname" is not the same as the username so I had the idea of
creating a simple txt file with :
And then parsing the "familyname" out of the file.
The problem is that I was able to parse the username out of the txt
file but not the "familyname"...
How do I get that out of the txt file? Do I use file_get_contents?
I read about it but it didn't make sense since I don't want the whole
file in one single array....
- » libcurl - how to simulate multiple file upload in array
- — Previous thread in » PHP Scripting Forum