Php 例如,编辑模式下的表情符号显示img标记而不是:D
所以,当用户输入description:D时,它会显示正确的笑脸图像,但当用户进入编辑模式时,会显示img标记。我需要显示:D而不是img标签。以下是完整的代码:Php 例如,编辑模式下的表情符号显示img标记而不是:D,php,html,Php,Html,所以,当用户输入description:D时,它会显示正确的笑脸图像,但当用户进入编辑模式时,会显示img标记。我需要显示:D而不是img标签。以下是完整的代码: $descr="some text :D"; $chars=array(":D", "^_^", ":P", ":(", ":)", "<3"); $icons=array("<img src='css/s/d.png' title='Happy' width='20px' height='20px' style='mar
$descr="some text :D";
$chars=array(":D", "^_^", ":P", ":(", ":)", "<3");
$icons=array("<img src='css/s/d.png' title='Happy' width='20px' height='20px' style='margin-bottom:-2px;'>"
,"<img src='css/s/donja.png' title='Very happy' width='20px' height='20px' style='margin-bottom:-2px;'>"
,"<img src='css/s/tong.png' title='Tongue' width='20px' height='20px' style='margin-bottom:-2px;'>"
,"<img src='css/s/sad.png' title='Sad' width='20px' height='20px' style='margin-bottom:-2px;'>"
,"<img src='css/s/gornja.png' title='Smile' width='20px' height='20px' style='margin-bottom:-2px;'>"
,"<img src='css/s/heart.png' title='heart' width='20px' height='20px' style='margin-bottom:-2px;'>"
);
$ades = str_replace($chars,$icons,$descr);
<div id="bio-data"> ///normal display mode
<i><?php echo $ades; ?></i>
</div>
<textarea id='ebio-datat' placeholder="Tell somehting about yourself" maxlength=300> ///edit mode
<?php echo $ades; ?>
</textarea>
$descr=“一些文本:D”;
$chars=array(“:D”、“^^”、“:P”、“:(“,”:)”、“只是回显$descr而不是$ades
因此,php:
<?php
$descr="some text :D";
$chars=array(":D", "^_^", ":P", ":(", ":)", "<3");
$icons=array("<img src='css/s/d.png' title='Happy' width='20px' height='20px' style='margin-bottom:-2px;'>"
,"<img src='css/s/donja.png' title='Very happy' width='20px' height='20px' style='margin-bottom:-2px;'>"
,"<img src='css/s/tong.png' title='Tongue' width='20px' height='20px' style='margin-bottom:-2px;'>"
,"<img src='css/s/sad.png' title='Sad' width='20px' height='20px' style='margin-bottom:-2px;'>"
,"<img src='css/s/gornja.png' title='Smile' width='20px' height='20px' style='margin-bottom:-2px;'>"
,"<img src='css/s/heart.png' title='heart' width='20px' height='20px' style='margin-bottom:-2px;'>"
);
$ades = str_replace($chars,$icons,$descr);?>
正常模式:
<div id="bio-data"> ///normal display mode
<i><?php echo $ades; ?></i>
</div>
///正常显示模式
编辑模式:
<textarea id='ebio-datat' placeholder="Tell somehting about yourself" maxlength=300> ///edit mode
<?php echo $descr; ?>
</textarea>
///编辑模式
只需回显$descr而不是$ades
因此,php:
<?php
$descr="some text :D";
$chars=array(":D", "^_^", ":P", ":(", ":)", "<3");
$icons=array("<img src='css/s/d.png' title='Happy' width='20px' height='20px' style='margin-bottom:-2px;'>"
,"<img src='css/s/donja.png' title='Very happy' width='20px' height='20px' style='margin-bottom:-2px;'>"
,"<img src='css/s/tong.png' title='Tongue' width='20px' height='20px' style='margin-bottom:-2px;'>"
,"<img src='css/s/sad.png' title='Sad' width='20px' height='20px' style='margin-bottom:-2px;'>"
,"<img src='css/s/gornja.png' title='Smile' width='20px' height='20px' style='margin-bottom:-2px;'>"
,"<img src='css/s/heart.png' title='heart' width='20px' height='20px' style='margin-bottom:-2px;'>"
);
$ades = str_replace($chars,$icons,$descr);?>
正常模式:
<div id="bio-data"> ///normal display mode
<i><?php echo $ades; ?></i>
</div>
///正常显示模式
编辑模式:
<textarea id='ebio-datat' placeholder="Tell somehting about yourself" maxlength=300> ///edit mode
<?php echo $descr; ?>
</textarea>
///编辑模式
只需回显$descr而不是$ades
因此,php:
<?php
$descr="some text :D";
$chars=array(":D", "^_^", ":P", ":(", ":)", "<3");
$icons=array("<img src='css/s/d.png' title='Happy' width='20px' height='20px' style='margin-bottom:-2px;'>"
,"<img src='css/s/donja.png' title='Very happy' width='20px' height='20px' style='margin-bottom:-2px;'>"
,"<img src='css/s/tong.png' title='Tongue' width='20px' height='20px' style='margin-bottom:-2px;'>"
,"<img src='css/s/sad.png' title='Sad' width='20px' height='20px' style='margin-bottom:-2px;'>"
,"<img src='css/s/gornja.png' title='Smile' width='20px' height='20px' style='margin-bottom:-2px;'>"
,"<img src='css/s/heart.png' title='heart' width='20px' height='20px' style='margin-bottom:-2px;'>"
);
$ades = str_replace($chars,$icons,$descr);?>
正常模式:
<div id="bio-data"> ///normal display mode
<i><?php echo $ades; ?></i>
</div>
///正常显示模式
编辑模式:
<textarea id='ebio-datat' placeholder="Tell somehting about yourself" maxlength=300> ///edit mode
<?php echo $descr; ?>
</textarea>
///编辑模式
只需回显$descr而不是$ades
因此,php:
<?php
$descr="some text :D";
$chars=array(":D", "^_^", ":P", ":(", ":)", "<3");
$icons=array("<img src='css/s/d.png' title='Happy' width='20px' height='20px' style='margin-bottom:-2px;'>"
,"<img src='css/s/donja.png' title='Very happy' width='20px' height='20px' style='margin-bottom:-2px;'>"
,"<img src='css/s/tong.png' title='Tongue' width='20px' height='20px' style='margin-bottom:-2px;'>"
,"<img src='css/s/sad.png' title='Sad' width='20px' height='20px' style='margin-bottom:-2px;'>"
,"<img src='css/s/gornja.png' title='Smile' width='20px' height='20px' style='margin-bottom:-2px;'>"
,"<img src='css/s/heart.png' title='heart' width='20px' height='20px' style='margin-bottom:-2px;'>"
);
$ades = str_replace($chars,$icons,$descr);?>
正常模式:
<div id="bio-data"> ///normal display mode
<i><?php echo $ades; ?></i>
</div>
///正常显示模式
编辑模式:
<textarea id='ebio-datat' placeholder="Tell somehting about yourself" maxlength=300> ///edit mode
<?php echo $descr; ?>
</textarea>
///编辑模式
两个选项:
echo str_replace($icons,$chars,$descr); //option 1
echo $descr; //option 2
我会做选择2
请参见代码板链接两个选项:
echo str_replace($icons,$chars,$descr); //option 1
echo $descr; //option 2
我会做选择2
请参见代码板链接两个选项:
echo str_replace($icons,$chars,$descr); //option 1
echo $descr; //option 2
我会做选择2
请参见代码板链接两个选项:
echo str_replace($icons,$chars,$descr); //option 1
echo $descr; //option 2
我会做选择2
参见代码板链接