I wanted to know if it was possible to write the following expression
while($row = mysql_fetch_array($result))
wit开发者_如何学运维h a "for loop" instead of a "while loop." So that the below code would print the same result.
while($row = mysql_fetch_array($result)){
echo $row['name'];
}
EDIT: I use PDO I just thought this would be an expression more people have seen. And as far as the answers go, yeah I agree it would be pointless. I'm just having trouble understanding how the internal pointer increments.
It would be really pointless, but you could do:
for(;$row = mysql_fetch_array($result);) {
echo $row['name'];
}
However, you should seriously consider using PDO.
for($row = NULL; $row = mysql_fetch_array($result);;) {
echo $row['name'];
}
精彩评论