Actually I think I have problems understanding the truth value of an assignment. The while keeps looping until the expression contained within it ($x=somefunction()) returns false.
So is the value of ($x=5) 5? And is it only false when somefunction returns nothing (or false)? And if ($x=5) has 5 as value, is 5 also TRUE (otherwise the while loop wouldn't run)?
A while loop will continue to evaluate the expression within the parenthesis for a statement of TRUE or FALSE. So, if you have a statement that says:
while($x < 100){ $x++; }
You'd be saying that while $x is negative, or between 0 and 99.999 (since in this case '0' is less than 100, and the equation would evaluate to true), then increment $x. Once $x is 100.000 or more, STOP the while loop.
So by saying something like:
while($row = mysql_fetch_array($result)){echo $row['item'];}
We are saying that "until the result of mysql_fetch_array() is 'FALSE', we want the array returned to the variable $row. If mysql_fetch_array() returns a FALSE value, then we'll stop the loop."
So, in your example:
So is the value of ($x=5) 5? And is it only false when somefunction returns nothing (or false)? And if ($x=5) has 5 as value, is 5 also TRUE (otherwise the while loop wouldn't run)?
First off, your syntax is incorrect. If you're wanting to compare the value against a number/string, then you need to use double equal signs (==) or triple for a strict comparison (===). You can read more on this in the PHP manual under "Comparison Operators". So, in your statement, you're setting the value of $x to 5. Since you're always setting it, it should always run in a continuous loop, unless you physically exit or break the loop.
If you were to compare the value of $x to 5, then if $x was anything but 5, it would not run. If $x was equal to 5, it would since 5 = 5.
Normally, while loops are done for ranges of numbers:
while( ($x<4) && ($x>6) ){ $x++; }
Or to do something while a function returns true (like mysql_fetch_array() or any function you write that returns anything but a FALSE value).
I hope I helped you out a bit if you didn't already understand, or get the kind of answer you wanted.
~Brett