What is the best practice for nesting variables with an index in PHP?

When nesting variables with an index in PHP, the best practice is to use curly braces to clearly define the variable names and indexes. This helps improve readability and avoid any confusion with variable names that contain numbers or special characters.

// Example of nesting variables with an index using curly braces
$users = [
    ['name' => 'John', 'age' => 30],
    ['name' => 'Jane', 'age' => 25]
];

foreach ($users as $key => $user) {
    echo "User {$key}: {$user['name']} is {$user['age']} years old. <br>";
}