Laravel Blade Switch Case Example

10-Apr-2023

.

Admin

Hi Guys,

In this blog, i will show you how to use switch case in laravel blade. We will learn you laravel blade switch case example. We want to share with you laravel switch case statements.In this post we will show you Blade syntax for switch case.

Switch statements can be constructed using the @switch, @case, @break, @default and @endswitch directives:

Here i will give you syntax and example for laravel blade switch case example, So let's see the bellow example:

Syntax


@switch($i)

@case(1)

First case...

@break

@case(2)

Second case...

@break

@default

Default case...

@endswitch

Example

<!DOCTYPE html>

<html>

<head>

<title>Laravel Blade Switch Case Example - NiceSnippets.com</title>

</head>

<body>

@switch($i)

@case(1)

First case...

@break

@case(2)

Second case...

@break

@default

Default case...

@endswitch

</body>

</html>

It will help you....

#Laravel 8

#Laravel 7

#Laravel

#Laravel 6