How to select a text within a string using php

Asked

Viewed 23 times

0

I am using PHP. I would like to select a name or several according to what is passed in a string, and return that selection in bold. Ex:

This code already returns my name, but only if it is a compound word or words that are together. Do not select letters in the word and do not return separate words

   $selNomeGuerra= array(
              $nomedeguerra =>"<strong>$nomedeguerra</strong>"
            );



           $nomeNovo =  strtr($nomecompleto, $selNomeGuerra );





$nomecompleto = "FRANCISCO JOAO DA SILVA SOUZA";

$nomedo usuario = "J SOUZA";

I would like to put together a list with the full name and the user name in bold, this was an example of name, but could be several other situations.

Then it would return the list to like this: $nameEdit = "FRANCISCO JOAO DA SILVA SOUZA"

To make it simpler, what..

the user passes you a text, composed or not, with isolated characters or not, as shown above, and returns to him the whole string with what he passed me, in my case I search in the database, return the complete string with the selected characters in bold.

The biggest problem and select ..

  • There is no "select" in [tag:php], this is not Javascript! from what I understand, you would need references to return a string formatted accordingly..

  • Please add more details to your question, your attempts, clarify as much as possible! I suggest edit her, and add these criteria to a [Mre] and How to ask a good question?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.