Re: Re: Cry for help

From: Date: Sat, 14 Sep 2002 02:18:40 +0000
Subject: Re: Re: Cry for help
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-116344@lists.php.net to get a copy of this message
Joakim, thats the kind of help I'm looking for For those who repeated it..I DO have the PHP.net manual, and its no help at this point. To me its like when I first moved here to Italy, I knew how to say 3 words in Italian. I couldn't learn any Italian by only hearing it and seeing it. Dictionaries werent much help. How much help would it be, if I wanted to ask about something I didnt understand, and I was answered in the exact same language I was confused about? Like so: Italian person: "Ciao, di dove sei?" Me: "I'm sorry I dont understand" Italian person: "Voleva dire che io voglio sapere di quale stato vieni!" See what I mean? I wouldn't ever get it that way. It wasn't until I met a few English speaking ppl that I finally began to learn Italian. So then the conversation was like this: Italian person: "Ciao, di dove sei?" Me: "I'm sorry I dont understand" Italian person: "Oh, well literally it means "Hi, of where are you?", but we say things in that way. The grammar is a little different in Italian" After 4 years I speak it fluently. The same way I am going to get to learn PHP. Slowly, and by having thigns explained in a way that I can understand. The PHP manual asnwers everything in PHP jargon and codes...makes no sense. Just like the Italian person in my first example. Once I find something that is more clear, then I'll get somewhere with it I'm looking through some code and I see something I dont understand, so I try to look it up in the manual, and either A) i cant find it. B) I find it, and the answer is something like "loop here, parse this, replicate the that while and transport 8-bit layers. Oh, and while you are at it, slit your wrist" I wont get anywhere with that. Does anyone know of some type of list of the syntaxes that i can refer to when I see code in a script? By going to my "syntax sheet" I can see how it must be written and in which order? Everything down to the simplest + or % sign! Thanks again everyone -Tree Joakim Andersson <joakim.andersson@cybercom.se> wrote in message news:791CA4EB1F1AD2119BB900062905C91F02CE80C0@adam.cybercom.se... > For example: > > while (!feof ($fp)) > > What does the ! mean or do? ! means not. > What does feof mean? is it one command? or is f e o f all different? feof() is a function that checks if a file has reached the end or not. (eof = end of file) while (!feof ($fp)) in whole means something like this As long as the filepointer ($fp) is not at the end, do whatever that's between { and } over and over again... > Why are there 2 ) at the end? Just because :-) The first ) belongs to feof and the second ) belongs to while. > > $buffer = fgets($fp, 4096); > > Why does it need a buffer? What is a buffer? $buffer is just a variable that stores the result of fgets(). It could be any name really... > > $arr = explode("|", $buffer); > > It's questions like that. I can understand more or less what > the meanings > are of the concepts. Another example of this is, I tested > your code, and it > returned the string > > SangiovanneseFlorentia Viola > > on one line only. If I want it to look like this:? > > Sangiovannese > Florentia Viola > > Now i now the \n means to go to the next line, but where > would I put that? You modify this line echo $arr[4]; to this echo $arr[4] . "\n"; // The . is a string concatenation operator. It simply joins the two strings. Now this would give you the same result in your browser, but if you view the source in the browser you will see that the lines are separated. To do a line break in the browser you have to insert the correct html (<br>) instead. > You see my dilemmas no? I wish I could find a list of syntax > and functions > like a reference guide. That would be a start www.php.net/manual/en/ is a very good start. > > Tack again > -Tree Varsågod! Joakim > > ----- Original Message ----- > From: Joakim Andersson <joakim.andersson@cybercom.se> > Newsgroups: php.general > To: <php-general@lists.php.net> > Sent: Thursday, September 12, 2002 4:54 PM > Subject: RE: [PHP] Re: Cry for help > > > > > |Serie C2 Round 2|09.09.02|20.45|Sangiovannese|Florentia Viola > > > |Serie C2 Round 2|09.09.02|20.45|Gualdo|Florentia Viola > > > > > > So for example, lets say I wanted to make another html form > > > that has a form > > > field for List team by: and and select either "home" or > "away" ... by > > > selecting "home", the browser would print out the following: > > > > > > Sangiovannese > > > Gualdo > > > > > > so now I need to figure out how to get PHP to do the following: > > > > > > #1 look at each line in the text file and treat it individually > > > #2 select the data after the 4th | from each line > > > #3 print it back to the browser > > > > $fd = fopen ("/tmp/inputfile.txt", "r"); // Opens file for reading > > while (!feof ($fd)) // Start of loop. > > { > > $buffer = fgets($fd, 4096); // Reads one line of > maximum 4096 bytes > > $arr = explode("|", $buffer); // Divides each row into separate > elements > > in an array. > > echo $arr[4]; // Prints the 5th element of each row. > > // The first element ($arr[0]) is actually "" (an empty > string) since each > > line starts with |. > > } > > fclose ($fd); > > > > Hopefully this will get you in the right direction. > > Regards > > Joakim Andersson >

« previous php.general (#116344) next »