@php tag in blade template can’t reach inline variable

I am looping through products which has all my configurable options available. Inside that i am looping through my items, when i get a match in product i want to display this product and item.

To do so i want to create a variable called $currentProduct.

@foreach($order['products'] as $product) // Configurable products
    @foreach($order['items'] as $item)  // Simple products
        @if ($item['product_type'] == 'simple')
            @if ($product['id'] === $item['product_id'])
                @php($currentProduct = $product) // error here $product undefined
                @php($currentItem = $item) // error here $item undefined
            @endif
        @elseif ($item['product_type'] == 'configurable')
            @if ($product['id'] == $item['parent_item']['product_id'])
                @php($currentProduct = $product) // error here $product undefined
                @php($currentItem = $item) // error here $item undefined
            @endif
        @endif
    @endforeach
@endforeach

I am new to laravel and blade templates and can’t seem to wrap my head around, why $product and $item is undefined when they are defined right above in same template.

Any help appreciated