@php $content = preg_replace_callback( '/(.*?)<\/h[1-3]>/', function ($matches) { $level = $matches[1]; $title = $matches[2]; $id = Str::slug(strip_tags($title)); return "$title"; }, $blog->content ); echo $content; @endphp