Well, for example: We have an input form:
<input type='text' name='text_user'> And the user entered such a message:
ΠΡΠΈΠ²Π΅ΡΠΈΠΊ Π²ΡΠ΅ΠΌ :)
How to draw a smiley :) and replace it with a picture, for example such -> <img src='Smile_1.jpg'>
Well, for example: We have an input form:
<input type='text' name='text_user'> And the user entered such a message:
ΠΡΠΈΠ²Π΅ΡΠΈΠΊ Π²ΡΠ΅ΠΌ :)
How to draw a smiley :) and replace it with a picture, for example such -> <img src='Smile_1.jpg'>
There are a lot of solutions.
You can just do
<? $string = "ΠΡΠΈΠ²Π΅ΡΠΈΠΊ Π²ΡΠ΅ΠΌ :)"; $pattern = ":)"; // ΡΡΡ ΠΌΠ°ΡΡΠΈΠ² ΡΠΎ ΡΠΌΠ°ΠΉΠ»Π°ΠΌΠΈ Π² Π²ΠΈΠ΄Π΅ ΡΠ΅ΠΊΡΡΠ° Π΄Π»Ρ Π·Π°ΠΌΠ΅Π½Ρ $replacement = "<img src='Smile_1.jpg'>"; // ΡΡΡ ΠΌΠ°ΡΡΠΈΠ² ΡΠΎ ΡΠΌΠ°ΠΉΠ»Π°ΠΌΠΈ Π² Π²ΠΈΠ΄Π΅ ΠΊΠ°ΡΡΠΈΠ½ΠΎΠΊ echo str_replace($pattern, $replacement, $string); ?> Write a little code and voila!
Google on the topic of implementation of bb code or on the topic of parsing. One of the examples with the description can be found here .
you can do it right away, javascriptom
<input id='text_user' type='text' name='text_user' onblur="set_smiles(this.id, this.value)"/> function set_smiles(id, value) { value = value.replace(':)','<img src="Smile_1.jpg">'); document.getElementById(id).value = value; } Source: https://ru.stackoverflow.com/questions/78731/
All Articles