I was thinking of doing something like this in PHP
function doSomething() { /* ... */ }
while(my_array[] = doSomething()) { }
instead of using extra variable : while(myValue = doSomething()) { myArray[] = myValue; }
Is using while block to do nothing good practice or not? And if it is not – why?
Yes, you can.
However, if you reevaluate the problem you’re trying to solve, you may find that a different approach or construct may prove better, and won’t require reducing the
whileconstruct to this purpose.