hi there
i am making a scrapbook application i which i have some emoticons also i had to make a preview section for writing a scrap in which i have to show the emoticons also that are written in the scrap ,i have completed the preview part with the help of javascript ,now i have to show those scraps along with the emoticons populated in the scrap book .The logic that i am using is to filter the scrap from the database just before they are populated in the scrapbook i tried to use the same logic as i used in the java script but it is not working quit right, i used the function str.replace() while using javascript but in php ihad to use the str_replace()
but it is not replacing the sign of the emoticon with the image tag. here is my code[code=php]
function stripperPhp($st r){
$arraysigns=arr ay("8)","*)",": @",":#",":o",": e",":s","*p" , "-p",":)",":D",": p",":$",":(" , ":w",":*",":x", ":-","8x","8|",":6 ",":&", "8*","$)","'(", "g(");
$arrayname=arra y("goggle.gif", "love.gif","hot .gif","sad.gif" ,"shock.gif" , "wacked.gif","p issed.gif", "horny.gif","di zzy.gif","smile .gif","happytee th.gif","tounge .gif", "shy.gif","disa p.gif","wot.gif ","kiss.gif","s hutup.gif","hol iday.gif", "army.gif","ner ed.gif","devil. gif","sadangle. gif", "kissdead.gif", "money.gif" , "money.gif","sw et.gif");
$stringlength=s trlen($str);
$arraylen=sizeo f($arraysigns);
for($j=0;$j<$ar raylen;$j++){
for($k=0;$k<$st ringlength;$k++ ){
$replaced=str_r eplace($arraysi gns[$j],"<img src=images/emoticons/".$arraynam e[$k]."/>",$str);
}
}
return $str;
}
function emoticn($str){
$replaced=strip perPhp($str);
echo "replaced=".$re placed;
}
[/code]
what i am doing in his code is that first i call a function emoticn($str); in which i pass the scrp as a string and then that string is passed to the
funtion stripperPhp($st r) which filters the string an replaces ':)' or any other smiley appearing in that string with the <img src='images/emoticons/smiley.gif'> i have stored the names of the smiley in an array and the name of the gifs fo that emoticons into another arrayand then use those array in the str_replace() funtion to swap the signs of smileys with the actual name of the gifs but it is not doing it so
any suggesstions
regards,
omer
i am making a scrapbook application i which i have some emoticons also i had to make a preview section for writing a scrap in which i have to show the emoticons also that are written in the scrap ,i have completed the preview part with the help of javascript ,now i have to show those scraps along with the emoticons populated in the scrap book .The logic that i am using is to filter the scrap from the database just before they are populated in the scrapbook i tried to use the same logic as i used in the java script but it is not working quit right, i used the function str.replace() while using javascript but in php ihad to use the str_replace()
but it is not replacing the sign of the emoticon with the image tag. here is my code[code=php]
function stripperPhp($st r){
$arraysigns=arr ay("8)","*)",": @",":#",":o",": e",":s","*p" , "-p",":)",":D",": p",":$",":(" , ":w",":*",":x", ":-","8x","8|",":6 ",":&", "8*","$)","'(", "g(");
$arrayname=arra y("goggle.gif", "love.gif","hot .gif","sad.gif" ,"shock.gif" , "wacked.gif","p issed.gif", "horny.gif","di zzy.gif","smile .gif","happytee th.gif","tounge .gif", "shy.gif","disa p.gif","wot.gif ","kiss.gif","s hutup.gif","hol iday.gif", "army.gif","ner ed.gif","devil. gif","sadangle. gif", "kissdead.gif", "money.gif" , "money.gif","sw et.gif");
$stringlength=s trlen($str);
$arraylen=sizeo f($arraysigns);
for($j=0;$j<$ar raylen;$j++){
for($k=0;$k<$st ringlength;$k++ ){
$replaced=str_r eplace($arraysi gns[$j],"<img src=images/emoticons/".$arraynam e[$k]."/>",$str);
}
}
return $str;
}
function emoticn($str){
$replaced=strip perPhp($str);
echo "replaced=".$re placed;
}
[/code]
what i am doing in his code is that first i call a function emoticn($str); in which i pass the scrp as a string and then that string is passed to the
funtion stripperPhp($st r) which filters the string an replaces ':)' or any other smiley appearing in that string with the <img src='images/emoticons/smiley.gif'> i have stored the names of the smiley in an array and the name of the gifs fo that emoticons into another arrayand then use those array in the str_replace() funtion to swap the signs of smileys with the actual name of the gifs but it is not doing it so
any suggesstions
regards,
omer
Comment