pandu Posted June 16, 2009 Share Posted June 16, 2009 Hi, Check out the code below. I dont understand how the while..do loop keeps looping because instead of having a condition, there is an assignment statement. Can someone explain how this loop is working? Shouldn't there be two equal symbols in those condition brackets? By the way, the function containing this code takes a table and adds $data to the $table. The code snippet below builds the query to add the data while (list($columns,) = each($data)) { $query .= ' ' . $columns . ' , '; } TIA Link to comment https://forums.phpfreaks.com/topic/162475-solved-how-is-this-while-do-loop-moving-forward/ Share on other sites More sharing options...
cunoodle2 Posted June 16, 2009 Share Posted June 16, 2009 It is some essence while there are still things to assign. If there are no longer things to assign then it will be false. It will loop through each one and assign them. Once there aren't any more to assign then it will no longer work. Make sense? Link to comment https://forums.phpfreaks.com/topic/162475-solved-how-is-this-while-do-loop-moving-forward/#findComment-857556 Share on other sites More sharing options...
pandu Posted June 16, 2009 Author Share Posted June 16, 2009 WOW! I would never have guessed that! Thanks Cunoodle - makes a lot of sense now. And I finally get how the query is being built. Link to comment https://forums.phpfreaks.com/topic/162475-solved-how-is-this-while-do-loop-moving-forward/#findComment-857561 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.