0
const EMOJI = [
    ":lol" => "http://localhost/chat/emoji/0046.gif",
    ":D" => "http://localhost/chat/emoji/0055.gif"
]

i want to use

EMOJI[:lol]

in src can anybody tell me how should i use it ?

case ":lol":
    echo "<img src='EMOJI[:lol]' width='32' height='32'>";
break;
1
  • I think quotation is the problem. Use the following: case ":lol": $emo = EMOJI[':lol']; echo "<img src='$emo' width='32' height='32'>"; break; Commented Jul 27, 2017 at 9:06

3 Answers 3

1

You have to escape quotes here. You can use like this:

echo "<img src='".EMOJI[':lol']."' width='32' height='32'>";
Sign up to request clarification or add additional context in comments.

Comments

0

Just like that:

echo "<img src='" . EMOJI[':lol'] . "' width='32' height='32'>";

Comments

0

Array key should be integer or string so you should use EMOJI[':lol'] instead of EMOJI[:lol];

Example

case ":lol":
    echo "<img src='".EMOJI[':lol']."' width='32' height='32'>";
break;

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.