Username:
Password:
Remember me:
Register

Back to forum: Web Programming (HTML, JS, CSS, PHP, MySQL)


Search forums via Google


0 Users appreciate this thread.

PHP Emoticons?
Started by angelrulez7
(2014-05-27 01:00:43)
angelrulez7 (2014-05-27 01:00:43)
I've been working on an emoticon system for a while, and it doesn't work EXACTLY how I want to. :/
[code=*php]<?php
/* Emote function by Neonacid64 */
function emote($text){
$icons = array(
'Below' => '<img src="/emote/smile.png" alt="">',
'Below' => '<img src="/emote/unhappy.png" alt="">',
'Below' => '<img src="/emote/wink.png" alt="">',
'Below' => '<img src="/emote/mad.png" alt="">',
'These don't work due to plaza' => '<img src="/emote/happy.png" alt="">',
'These don't work due to plaza' => '<img src="/emote/unsure.png" alt=":/">'
);
return strtr($text,$icons);
}
echo emote("http:// :/" );
?>
[/code]
This is the result.

What I want to happen is that it won't work if it's part of a word, like http:// or that stupid " bug here. Sort of like Splashiverse.

I tried Stack Overflow. No help.

How do I do this?

This post has been edited one or more times, the last time was:
2014-05-27 08:02:29

a
SPCOxion (2014-05-28 05:59:10)
The same thing happened to me with a censor() function

Someone typed 'Advertisement', and it returned 'Adverti*****t'

All I did was add spaces around it.

Source Code
preg_replace($input, array(' semen', 'semen ', ' semen ', array(' *****', '***** ', ' ***** ');


(Apologies if the code is wrong, lel. It's been forever since I've used/edited/looked at it)

Just edit your code to do something like that.

...and, if that doesn't work, call me an idiot and listen to what Mega says

This post has been edited one or more times, the last time was:
2014-06-02 12:24:03

angelrulez7 (2014-05-29 03:28:49)
My problem is that I want them to work when there's no spaces, as long as there's no character in front of it.
a
CoolApps (2014-05-29 19:44:14)
^^^ So it wouldn't get in eehhhhhhh I mean nothing...



I would use str_replace() or use an other strategy with the array() function.


Can you put the actual code in http://notepad.cc?

This post has been edited one or more times, the last time was:
2014-05-30 02:46:40

Newer account: NodePoint
angelrulez7 (2014-06-01 17:07:51)
LOL @mega

Uh, I wrote this code IN Notepad++, Leake.
a
SPCOxion (2014-06-02 05:23:34)
As long as there's no character in front of it?

Define 'character'.

If 'character' means 'space', then that's cpvered in the code I posted.

I highlighted the whitespace in front of the words and what I'm replacing them with, just so it's easier to see.
angelrulez7 (2014-06-05 06:46:48)
That will take long to redo, but I gotta do what I gotta do.

What if somebody, like for their bio, is just an emote, and it doesn't work?
a
angelrulez7 (2014-06-05 08:34:53)
I got it working.
a
 

This topic is closed, so you can not post a comment.

This topic's ID: 70091

Back to forum: Web Programming (HTML, JS, CSS, PHP, MySQL)




Total registered users: 8321
New registered users today: 7
Newest registered user: ElegantVulpes

©  Copyright 2026 3DSPlaza. All Rights Reserved