Да, это так.
A for цикл можно описать так: for (initialisation; alive condition; last loop statement)
его можно перевести с помощью цикла while
следующим образом:
initialisation
while (alive condition)
{
// some code
last loop statement
}
Вы ставите то, что хотите, при условии, что он учитывает операторы diffts
for($i = 1; count($ra) <= $quantity && isset($this->allRARooms); $i++) { }
эквивалентен
$i = 1;
while (count($ra) <= $quantity && isset($this->allRARooms))
{
// some code
$i++;
}
Вы можете добавить много операторов инициализации и последней инструкции и условие liveможет быть независимым от них.
$aConditionIndependantOfInit = true;
for ($i = 0, $j = 42; $aConditionIndependantOfInit; $i++, $j--)
{
echo "foo\n";
if ($i >= $j)
$aConditionIndependantOfInit = false;
}
Этот вывод 21 foo