What are the advantages and disadvantages of using a for loop to handle conditional variable assignment in PHP?

Using a for loop to handle conditional variable assignment in PHP can be advantageous when dealing with a large number of conditions that follow a pattern. It can make the code more concise and easier to maintain. However, it can also make the code harder to read and understand, especially for someone unfamiliar with for loops or complex logic.

// Example of using a for loop for conditional variable assignment
$conditions = ['condition1' => true, 'condition2' => false, 'condition3' => true];
$result = '';

for ($i = 1; $i <= count($conditions); $i++) {
    $condition = 'condition' . $i;
    
    if ($conditions[$condition]) {
        $result = $condition;
        break;
    }
}

echo $result;