[PHP] Read one word in file

2001-04-05 Thread Andrew V. Romero
I have a php script that reads a file that looks something like this: 1. Question One goes here: 2. Question two goes here: I need someway to have the script just read either the 1. or just the 1 When I first made the script I just had the program read the line using $questionBuffer = fgets($w

Re: [PHP] Read one word in file

2001-04-05 Thread Joe Stump
This is how I would do it ... --Joe On Thu, Apr 05, 2001 at 04:50:37PM -0700, Andrew V. Romero wrote: > I have a php script that reads a file that looks something like this: > > 1. Question One goes here: > 2. Question two goes here: > > I need someway to have the script just read either t

Re: [PHP] Read one word in file

2001-04-05 Thread Chris Fry
You might want to use:- $aryQbuff = file("/pathto/filename", "r"); You will then have each line of the file in an array. Then:- $intNumLines = count($aryQbuff); for($i=0;$i<=$intNumLines;$i++) { $intQnum = explode(".", $aryQbuff[$i]); // $intQnum now has the question number in it //

Re: [PHP] Read one word in file

2001-04-05 Thread Plutarck
Once you get the first line into an array, you can just use explode on \n, or use a regex that searches for any group of characters that is not a whitespace character, then stops searching once it's found it. As Chris said, there are many many ways of doing it. -- Plutarck Should be working on