@php $content = preg_replace('/

 <\/p>/', '', $content); // Mencocokkan semua paragraf yang valid preg_match_all('/

.*?<\/p>/', $content, $matches); $paragraphs = $matches[0]; // Array berisi paragraf $totalParagraphs = count($paragraphs); @endphp {{-- total: {{ $totalParagraphs }} --}}

@if ($totalParagraphs > 0) @foreach ($paragraphs as $index => $paragraph) {!! $paragraph !!} @if ($totalParagraphs >= 2 && $totalParagraphs < 10) @if ($index == 2 && $related->isNotEmpty())
@endif @if ($index == 2 && $related->isEmpty())
Advertisement
@endif @endif @if ($totalParagraphs > 9) @if ($index == 10 && $related->isNotEmpty())
@endif @if ($index == 16)
Advertisement
@endif @if ($index == 22 && $relatedmore->isNotEmpty())
@endif @if ($index == 28)
Advertisement
@endif @endif @endforeach @else {!! $content !!} @endif