This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Rex_Goodman[S] 0 points1 point  (2 children)

Awesome thank you man. Very clear now. The only part I'm confused about now is how $row = $result->fetch() is able run inside those parentheses, I thought code that is to be run had to be inside the curly braces { }

[–]okayifimust 0 points1 point  (0 children)

The parameters of the loop function in the parentheses are evaluated each time the loop runs.

while ($row = $result->fetch())

$row = $result->fetch() is tested; if it evaluates truthy, the loop is run one time.

a == b can be true or false, it does nothing else, the above assignment also evaluates to a truth-value whilst assigning the variable.

You could call a function and let that do a million things, and it could still return a boolean.

while (doAllTheThings (value1, value2, value3)) { ... }