What is the issue with using rand() in a loop in PHP?

Using `rand()` in a loop in PHP can lead to performance issues because `rand()` generates a new random number every time it is called, which can be computationally expensive. To solve this issue, you can generate all the random numbers you need outside the loop and then access them within the loop.

// Generate an array of random numbers before the loop
$randomNumbers = [];
for ($i = 0; $i < 10; $i++) {
    $randomNumbers[] = rand(1, 100);
}

// Use the pre-generated random numbers in the loop
foreach ($randomNumbers as $number) {
    echo $number . "\n";
}