I need to identify a word in the string and then add the tag "< strong >word< /strong > " around the word. It turns out that there are Words that start with an uppercase or lowercase letter, so I need to identify both cases and print the result with the tag around the word.
My code is like this:
@foreach($versiculos as $v)
<p>{{ $v->palavra }} </p>
@endforeach
my controller:
public function palavras(Request $request, $palavra = null)
{
$getpalavra = palavras_br::where('slug', $palavra)->first();
$versiculos = nvi::where('palavra', 'RLIKE','[[:<:]]'.$getpalavra->palavras.'[[:>:]]')->paginate(20);
return view('palavra', compact(['versiculos','getpalavra']));
}
Example:
string: "Adão teve relações com Eva, sua mulher, e ela engravidou e deu à luz Caim. Disse ela: "Com o auxílio do Senhor tive um filho homem".
I need to take the word "filho" and replace it with "< strong >filho< / strong >
But I need to keep the word the way it is, because it can appear with upper or lower case "filho" or "Filho" . And in both cases I need to wrap them by the < strong > tag.
How can I identify the word and add the tags around the word I need??