Welcome visitor
* Login
* Register
It is currently July 23rd, 2019, 7:22 am
All times are UTC [ DST ]
* Search
View unanswered posts - View active topics

FORUMS » Client Side » HTML



Post new topic Reply to topic  [ 2 posts ] 
Author Message
  Replace text with icons
PostPosted: November 9th, 2009, 10:21 pm 

Posts: 33
How can I replace letters with icons on the posts people make on my site so ": P" (without the space) will look like " :P " ???

Thank you.


Top
 Profile  
 
  Re: Replace text with icons
PostPosted: November 10th, 2009, 7:09 am 
User avatar

Posts: 86
This is the first time I try something like this and this is what I got using PHP (You'll need another language than HTML to parse and replace the strings for icons). This file should be named thisfilename.php in order to work and should be run from a server and not as a regular html.
<?php
extract($_POST);
if (!$theinput){}
else {
  $trans = array(
    ":P" => "<img src='P.jpg' />",
    "U_U" => "<img src='UU.jpg' />"
  );
  $theinput= strtr($theinput, $trans);
  }
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Replace text with icons</title>
</head>
<body>
<form action="thisfilename.php" method="post">
<textarea name="theinput"  cols="80" rows="10px"></textarea>
<input type="submit" value="POST">
</form>
<br />
<br />
The entry was:
<br />
<div id="theoutput"><?php echo $theinput; ?></div>
</body>
</html>

Hope this helps :P


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

FORUMS » Client Side » HTML


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron