0
Good evening, I have a big problem, is the following, I am with a textarea form to send texts to the database, and what I want to do is take a snippet or a word that is contained between certain characters and modify them to a tag... To clarify it is Thus:
Let’s suppose q want to take the text that is within two strokes(-): This is an example -Text- ... And the result I want is, whenever the user puts a word or an excerpt of the text between these two traits(-), I want to exchange them to:: This is a Text of Example.
I tried with str_replace, but could not get the desired result.
$text = $_POST['publicacaoText'];
$publicacaoStrip = str_replace("/*", "<b>", $text);
$publicacaoStrip = str_replace("*/", "</b", $publicacaoStrip);
So it even works, but like, if I put it twice in a row like this:: /Breno/ /Castro/... He does what I want, but does not add the Space between the two words, IE, I wanted to make the system bold and italic like Whatsapp -Breno- +Castro+, and I realized that here at stackoverflow also has the same system. Please if anyone can help me, I appreciate too many old.
I also warn you that I have tried this:
$publicacaoStrip = str_replace("-$text-", "<b>$text</b>", $publicacaoStrip);
OR
$publicacaoStrip = str_replace("-".$text."-", "<b>$text</b>", $publicacaoStrip);
And obviously it didn’t work kkkkk It was stupid to have tested like this, but I did it to make sure kkkk
Please guys, help me, I really need
If anyone knows how to do this also with Jquery too, but preferred is with PHP please
Dude, very Boom, helped me a lot, but please tell me something, like, you put it in for when you have the text between (-) it replace for (<b>), right up to there beauty, and if I want to put an extra function, like, the (-) is in bold and the (*) stays in Italian, what I have to modify in the code, would have to help me?
– Breno Castro
Edited with the proposed changes.
– Marcelo Shiniti Uchimura