Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

yougotnet's avatar

How to mix blade and php?

I'm using @foreach blade directive and in between I need to perform php functions on the item inside the foreach; how can this be achieved?

0 likes
4 replies
Sergiu17's avatar
Sergiu17
Best Answer
Level 60
@php
	// php 
@endphp

you could use @php blade directive

newbie360's avatar

can you provide any example code ?

@foreach ($items as $item)
    {{ ucfirst($item) }}
@endforeach
yougotnet's avatar

Sergui17 worked best because I had a lot of php manipulation I had to do on the item.

Thanks!

Please or to participate in this conversation.