Banner

Sponsor

Login


Welcome Back!
Guest
Guest

Register

Lost your password?

124 users online



str_replace for smileys, and br's (HELP)

str_replace for smileys, and br's (HELP)

Currently viewing this thread: 1 (0 members and 1 guests)


Page 2 out of 2
Zeratul

Zeratul

kage
Status: Offline!

No, it's the hard breaks.
I'll try the /n.
I also tried the nl2br before, didn't have luck.

EDIT:
doesn't work. Sad

sabrina

sabrina

what could you possibly want to know about me?
Status: Offline!

not /n - it must be \n

Edit: actually, I think pureevils's method is the best -
you should use that. Did you remember to assign the
result back into $theshout? (It really should work)

PHP:

<?php
$theshout 
nl2br($theshout)
?>

Last edited by sabrina, July 26th, 2004 12:55 AM (Edited 1 times)

aonic

aonic

Neversidian
Status: Offline!

i tryed ur code and it seems to work

http://aonic.net/tests/Untitled-1a.php?s=o_O

PHP:

<?php

$smile 
= array(
    
':\)' => '<img src="emoticons/smile.gif" alt=":\)" />',
    
'Sad=> '<img src="emoticons/sad.gif" alt="Sad" />',
    
':\D' => '<img src="emoticons/biggrin.gif" alt=":\D" />',
    
'o_O' => '<img src="emoticons/blink.gif" alt="o_O" />',
    
'Undecided=> '<img src="emoticons/mellow.gif" alt="Undecided" />',
    
'B-)' => '<img src="emoticons/cool.gif" alt="B-)" />',
    
'^_^' => '<img src="emoticons/happy.gif" alt="^_^" />',
    
':P' => '<img src="emoticons/tongue.gif" alt=":P" />',
    
'Laugh=> '<img src="emoticons/laugh.gif" alt="Laugh" />',
    
':\ohmy:' => '<img src="emoticons/ohmy.gif" alt=":\ohmy:" />',
    
';\)' => '<img src="emoticons/wink.gif" alt=";\)" />',
    
':wub:' => '<img src="emoticons/wub.gif" alt=":wub:" />',
    
':\mad:' => '<img src="emoticons/mad.gif" alt=":\mad:" />',
    
'-_-' => '<img src="emoticons/sleep.gif" alt="-_-" />',
    
':dry:' => '<img src="emoticons/dry.gif" alt=":dry:" />',
    
':ninja:' => '<img src="emoticons/ninja.gif" alt=":ninja:" />'
);
$stuff $_GET['s'];
echo 
str_replace(array_keys($smile), array_values($smile), $stuff);

?>

___________________

-Developer
-Forum Leader
-NeverNET

Alekz

Alekz

So what's up :)
Status: Offline!

I think this is easier for smiles :)

PHP:

<?php

$smile 
= array(
    
':)' => '<img src="emoticons/smile.gif" alt=":)" />',
    
':(' => '<img src="emoticons/sad.gif" alt=":(" />',
    
':D' => '<img src="emoticons/biggrin.gif" alt=":D" />',
    
'o_O' => '<img src="emoticons/blink.gif" alt="o_O" />',
    
':|' => '<img src="emoticons/mellow.gif" alt=":|" />',
    
'B-)' => '<img src="emoticons/cool.gif" alt="B-)" />',
    
'^_^' => '<img src="emoticons/happy.gif" alt="^_^" />',
    
':P' => '<img src="emoticons/tongue.gif" alt=":P" />',
    
':lol:' => '<img src="emoticons/laugh.gif" alt=":lol:" />',
    
':ohmy:' => '<img src="emoticons/ohmy.gif" alt=":ohmy:" />',
    
';)' => '<img src="emoticons/wink.gif" alt=";)" />',
    
':wub:' => '<img src="emoticons/wub.gif" alt=":wub:" />',
    
':mad:' => '<img src="emoticons/mad.gif" alt=":mad:" />',
    
'-_-' => '<img src="emoticons/sleep.gif" alt="-_-" />',
    
':dry:' => '<img src="emoticons/dry.gif" alt=":dry:" />',
    
':ninja:' => '<img src="emoticons/ninja.gif" alt=":ninja:" />'
);

$theshout nl2br(strtr($theshout,$smile));

?>

___________________

"¿Por qué buscais la felicidad, oh, mortales, fuera de vosotros mismos?"
~Boecio

Zeratul

Zeratul

kage
Status: Offline!

What does strtr do?

aonic

aonic

Neversidian
Status: Offline!

http://php.net/strtr

___________________

-Developer
-Forum Leader
-NeverNET

BigToach

BigToach

Neversidian
Status: Offline!

its basically the same thing. however in some weird cases you can get weird results with that method. but i must emphasize some cases

___________________

Neverside Development Director
PHP Snippets
BigToach.com - IT WORKS, TOACHY!

Zeratul

Zeratul

kage
Status: Offline!

Praise you Alekz! Shocked
Thanks very much! Wink

Page 2 out of 2
Quick Jump:

Main Navigation


Site & Graphic Design by Aeon Tan
Developed by Jeremie Pelletier & Scott Roach


NeverAPI generated this page in 0.0113 seconds.