This example shows how to use @if to greet an admin user, @foreach to list tasks, and @for to count down from 3.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Control Structures Example</title>
</head>
<body>
@php
$user = (object) ['name' => 'Alice', 'isAdmin' => function() { return true; }];
$tasks = ['Buy milk', 'Write code', 'Read book'];
@endphp
@if ($user->isAdmin())
<h1>Welcome, Admin {{ $user->name }}!</h1>
@else
<h1>Welcome, Guest!</h1>
@endif
<h2>Your Tasks:</h2>
<ul>
@foreach ($tasks as $task)
<li>{{ $task }}</li>
@endforeach
</ul>
<h2>Countdown:</h2>
@for ($i = 3; $i > 0; $i--)
<p>{{ $i }}</p>
@endfor
</body>
</html>