Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9022201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:26:45+00:00 2026-06-16T05:26:45+00:00

Well, I would make it easier to add smileys and the code it should

  • 0

Well, I would make it easier to add smileys and the code it should be replaced with a bit easier, So insted of creating 2 arrays, I would like to only have one.
So this is a example how I wanted it.
$Smileys = array(“:D” => “”);

So instead of using it like
$Smileys = array(“:D”);
$SmileyReplace = array(“”);
But is it possible at all?
I can’t seem to find something on Google that helps.

My new code that I wanted to use and the old.
New:

function fixSmileys($Data) {
        $Smileys = array(
        ":D" => '<img src="/application/modules/Chat/externals/images/smilies/grin.png" title=":D" alt=":D"/>',
        ":)" => '<img src="/application/modules/Chat/externals/images/smilies/smile.png" title=":)" alt=":)"/>',
        ":P" => '<img src="/application/modules/Chat/externals/images/smilies/tongue.png" title=":P" alt=":P"/>',
        ":S" => '<img src="/application/modules/Chat/externals/images/smilies/confused.png" title=":S" alt=":S"/>',
        ":'(" => '<img src="/application/modules/Chat/externals/images/smilies/cry.png" title=":'."'".'(" alt=":Cry:"/>',
        ":$" => '<img src="/application/modules/Chat/externals/images/smilies/embarrassed.png" title=":$" alt=":$"/>',
        ":(" => '<img src="/application/modules/Chat/externals/images/smilies/frown.png" title=":(" alt=":("/>',
        ":@" => '<img src="/application/modules/Chat/externals/images/smilies/mad.png" title=":@" alt=":@"/>',
        ";)" => '<img src="/application/modules/Chat/externals/images/smilies/wink.png" title=";)" alt=";)"/>',
        "B)" => '<img src="/application/modules/Chat/externals/images/smilies/cool.png" title="B)" alt="B)"/>',
        ":|" => '<img src="/application/modules/Chat/externals/images/smilies/neutral.png" title=":|" alt=":|"/>',
        ":lol:" => '( ?° ?? ?°)',
        ":derp:" => '<img src="/application/modules/Chat/externals/images/smilies/derp.png" title=":derp:" alt=":derp:"/>',
        ";D" => '<img src="/application/modules/Chat/externals/images/smilies/awesome.png" title=";D" alt=";D"/>',
        ":troll:" => '<img src="/application/modules/Chat/externals/images/smilies/troll.png" title=":troll:" alt=":troll:"/>',
        ":spin:" => '<img src="/application/modules/Chat/externals/images/smilies/abspin.gif" title=":spin:" alt=":spin:"/>',
        ":love:" => '<img src="/application/modules/Chat/externals/images/smilies/heart.png" title=":love:" alt=":love:"/>',
        ":sick:" => '<img src="/application/modules/Chat/externals/images/smilies/sick.png" title=":lol:" alt=":sick:"/>',
        ":O_O:" => '<img src="/application/modules/Chat/externals/images/smilies/sawut.png" title=":O_O:" alt=":O_O:"/>',
        ":bath:" => '<img src="/application/modules/Chat/externals/images/smilies/bath-time.png" title=":bath:" alt=":bath:"/>',
        ":socks:" => '<img src="/application/modules/Chat/externals/images/smilies/socks.png" title=":socks:" alt=":socks:"/>',
        ":boss:" => '<img src="/application/modules/Chat/externals/images/smilies/SuitBozzsmiley.png" title=":boss:" alt=":boss:"/>',
        ":potato:" => '<img src="/application/modules/Chat/externals/images/smilies/potatoes.png" title=":potato:" alt=":potato:"/>');
        return $Smileys[$Data];
}

And the old code that I currenty use that uses only str_replace and alot of lines.

function fixSmileys($Data) {
        $xCommentx = $Data;
    $xCommentx1 = str_replace(":D", '<img src="/application/modules/Chat/externals/images/smilies/grin.png" title=":D" alt=":D"/>', $xCommentx);
    $xCommentx2 = str_replace(":)", '<img src="/application/modules/Chat/externals/images/smilies/smile.png" title=":)" alt=":)"/>', $xCommentx1);
    $xCommentx3 = str_replace(":P", '<img src="/application/modules/Chat/externals/images/smilies/tongue.png" title=":P" alt=":P"/>', $xCommentx2);
    $xCommentx4 = str_replace(":S", '<img src="/application/modules/Chat/externals/images/smilies/confused.png" title=":S" alt=":S"/>', $xCommentx3);
    $xCommentx5 = str_replace(":'(", '<img src="/application/modules/Chat/externals/images/smilies/cry.png" title=":'."'".'(" alt=":Cry:"/>', $xCommentx4);
    $xCommentx6 = str_replace(":$", '<img src="/application/modules/Chat/externals/images/smilies/embarrassed.png" title=":$" alt=":$"/>', $xCommentx5);
    $xCommentx7 = str_replace(":(", '<img src="/application/modules/Chat/externals/images/smilies/frown.png" title=":(" alt=":("/>', $xCommentx6);
    $xCommentx8 = str_replace(":@", '<img src="/application/modules/Chat/externals/images/smilies/mad.png" title=":@" alt=":@"/>', $xCommentx7);
    $xCommentx9 = str_replace(";)", '<img src="/application/modules/Chat/externals/images/smilies/wink.png" title=";)" alt=";)"/>', $xCommentx8);
    $xCommentx10 = str_replace("B)", '<img src="/application/modules/Chat/externals/images/smilies/cool.png" title="B)" alt="B)"/>', $xCommentx9);
    $xCommentx11 = str_replace(":lol:", '( ͡° ͜ʖ ͡°)', $xCommentx10);
    $xCommentx12 = str_replace(":derp:", '<img src="/application/modules/Chat/externals/images/smilies/derp.png" title=":derp:" alt=":derp:"/>', $xCommentx11);
    $xCommentx13 = str_replace(";D", '<img src="/application/modules/Chat/externals/images/smilies/awesome.png" title=";D" alt=";D"/>', $xCommentx12);
    $xCommentx14 = str_replace(":troll:", '<img src="/application/modules/Chat/externals/images/smilies/troll.png" title=":troll:" alt=":troll:"/>', $xCommentx13);
    $xCommentx15 = str_replace(":approve:", '<img src="/application/modules/Chat/externals/images/smilies/approved.png" title=":approve:" alt=":approve:"/>', $xCommentx14);
    $xCommentx16 = str_replace(":lolol:", '<img src="/application/modules/Chat/externals/images/smilies/lolol.png" title=":brohoof:" alt=":brohoof:"/>', $xCommentx15);
    $xCommentx17 = str_replace(":asdf:", '<img src="/application/modules/Chat/externals/images/smilies/asdf.png" title=":facehoof:" alt=":facehoof:"/>', $xCommentx16);
    $xCommentx18 = str_replace(":spin:", '<img src="/application/modules/Chat/externals/images/smilies/abspin.gif" title=":spin:" alt=":spin:"/>', $xCommentx17);
    $xCommentx19 = str_replace(":love:", '<img src="/application/modules/Chat/externals/images/smilies/heart.png" title=":love:" alt=":love:"/>', $xCommentx18);
    $xCommentx20 = str_replace(":sick:", '<img src="/application/modules/Chat/externals/images/smilies/sick.png" title=":lol:" alt=":sick:"/>', $xCommentx19);
    $xCommentx21 = str_replace(":O_O:", '<img src="/application/modules/Chat/externals/images/smilies/sawut.png" title=":O_O:" alt=":O_O:"/>', $xCommentx20);
    $xCommentx22 = str_replace(":bath:", '<img src="/application/modules/Chat/externals/images/smilies/bath-time.png" title=":bath:" alt=":bath:"/>', $xCommentx21);
    $xCommentx23 = str_replace(":socks:", '<img src="/application/modules/Chat/externals/images/smilies/socks.png" title=":socks:" alt=":socks:"/>', $xCommentx22);
    $xCommentx24 = str_replace(":boss:", '<img src="/application/modules/Chat/externals/images/smilies/SuitBozzsmiley.png" title=":boss:" alt=":boss:"/>', $xCommentx23);
    $xCommentx25 = str_replace(":potato:", '<img src="/application/modules/Chat/externals/images/smilies/potatoes.png" title=":potato:" alt=":potato:"/>', $xCommentx24);
    $xCommentxFinal = str_replace(":|", '<img src="/application/modules/Chat/externals/images/smilies/neutral.png" title=":|" alt=":|"/>', $xCommentx25);
    return $xCommentxFinal;
}

The currenty code works as follow, The $Data that is being feeded contains like “Hello world :D” So it goes thru all the str_replaces until it finds the match and replaces it with a html code.
But I would just like to have it like the New, but useless nonworking code.
The reason I would like have it like that is to have it easier to add smileys to the site.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T05:26:46+00:00Added an answer on June 16, 2026 at 5:26 am

    There is a simple way of doing this using strtr. See documentation and examples http://php.net/manual/en/function.strtr.php

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The UserControl below works well but I would like to make it easier to
The UserControl below works well but I would like to make it easier to
I am looking for some code (either PHP or JavaScript) would work well to
Ok well heres what I would like to do in PHP: http://www.wordle.net/ I know
I would like to know how difficult it would be to merge the well-designed
Well, the question says it all. What I would like to do is that,
Which amongst these would be well suited for a scalable server side TCP socket
I'm working on a piece of software that would work well with an iTunes
Well when designing this site I thought it would be clever to lay everything
Well, for integers I would use NSNumber . But YES and NO aren't objects,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.