SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2001
    Location
    Tucson, AZ
    Posts
    80
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    php and emoticons

    Anyone know of something I can input or a script that will turn text smilies and stuff into graphical ones? pretty much you have : ) on your site it changes it to . it kinda intercepts the smilies and replaces them with html code pointing to a graphical version.

  2. #2
    :) delemtri's Avatar
    Join Date
    Jun 2001
    Posts
    579
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    str_replace("", "<img src=\"images/smileforthecameradear.gif\">", $stuff);

  3. #3
    SitePoint Enthusiast
    Join Date
    Jul 2001
    Location
    Tucson, AZ
    Posts
    80
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    would that work if i put that in the head of my document?

  4. #4
    :) delemtri's Avatar
    Join Date
    Jun 2001
    Posts
    579
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Put it in the PHP wherever the information is going to be processed.

  5. #5
    SitePoint Enthusiast
    Join Date
    Jul 2001
    Location
    Tucson, AZ
    Posts
    80
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well i am loading my site news off a text file... i want it to process the text file and do the changes.

  6. #6
    :) delemtri's Avatar
    Join Date
    Jun 2001
    Posts
    579
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah. Get the text file into the $stuff variable and then use that code.

  7. #7
    SitePoint Enthusiast
    Join Date
    Jul 2001
    Location
    Tucson, AZ
    Posts
    80
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Would something like this work?
    Code:
    <?
    $stuff = "inc/blah.inc";
    str_replace(":)", "<img src=\"images/smileforthecameradear.gif\">", $stuff);
    include ("inc/blah.inc");
    ?>
    Last edited by therunes; Aug 10, 2001 at 14:17.

  8. #8
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No that won't work but this will.

    PHP Code:
    $fp fopen("inc/blah.inc""r");
    if(
    $fp) {
        while(!
    feof($fp)) {
            
    $stuff .= fgets($fp1024);    
            }
        
    fclose($fp);
        
    $stuff str_replace(":)""<img src=\"images/smileforthecameradear.gif\">"$stuff);
        }
    else {
        print 
    "Could not open file";
        }
    print 
    $stuff
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  9. #9
    SitePoint Enthusiast
    Join Date
    Jul 2001
    Location
    Tucson, AZ
    Posts
    80
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I got it to work... heres my php file

    PHP Code:
    <html>
    <head>
        <title>Untitled</title>
        <?
    function Do_faces ($article) {
    $article nl2br($article);
    $article str_replace(":)","<img src=\"/images/smiles/smile.gif\" height=\"15\" width=\"15\" border=\"0\" alt=\"\">",$article);
    $article str_replace(":-)","<img src=\"/images/smiles/smile.gif\" height=\"15\" width=\"15\" border=\"0\" alt=\"\">",$article);
    $article str_replace(":E","<img src=\"/images/smiles/teeth.gif\" height=\"15\" width=\"15\" border=\"0\" alt=\"\">",$article);
    $article str_replace(":p","<img src=\"/images/smiles/tongue.gif\" height=\"15\" width=\"15\" border=\"0\" alt=\"\">",$article);
    $article str_replace(">:(","<img src=\"/images/smiles/angry.gif\" height=\"15\" width=\"15\" border=\"0\" alt=\"\">",$article);
    $article str_replace(":(","<img src=\"/images/smiles/sad.gif\" height=\"15\" width=\"15\" border=\"0\" alt=\"\">",$article);
    $article str_replace(";(","<img src=\"/images/smiles/cry.gif\" height=\"15\" width=\"15\" border=\"0\" alt=\"\">",$article);
    $article str_replace(":-(","<img src=\"/images/smiles/sad.gif\" height=\"15\" width=\"15\" border=\"0\" alt=\"\">",$article);
    $article str_replace(":\\","<img src=\"/images/smiles/hmm.gif\" height=\"15\" width=\"15\" border=\"0\" alt=\"\">",$article);
    $article str_replace(":o","<img src=\"/images/smiles/embaressed.gif\" height=\"15\" width=\"15\" border=\"0\" alt=\"\">",$article);
    $article str_replace(";)","<img src=\"/images/smiles/wink.gif\" height=\"15\" width=\"15\" border=\"0\" alt=\"\">",$article);
    $article str_replace(";-)","<img src=\"/images/smiles/wink.gif\" height=\"15\" width=\"15\" border=\"0\" alt=\"\">",$article);
    $article str_replace(":Y","<img src=\"/images/smiles/pants.gif\" height=\"15\" width=\"15\" border=\"0\" alt=\"\">",$article);
    return 
    $article;
    }
    ?>
    <?
     $textfile 
    file("test.inc");                                          
     
    $textfile implode(""$textfile);                                         
                                                                                
                                                                                
     
    $textfile Do_faces($textfile); 
    ?>
    </head>

    <body>
    <? print $textfile?>
    </body>
    </html>
    Thanks guys... :)
    Last edited by therunes; Aug 10, 2001 at 16:04.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •